Menu

Instructions Log in to Edit

John Cipriano

Given a package containing Java source files and a file called invariants.json, CheckInv will generate derived classes which can be used as a drop-in replacement for unit tests, and which will alert you if any of their invariants fail to hold.

To use the tool:

  1. Back up your project. The plugin is still alpha software.
  2. Make an invariants.json file. See [Invariants file format] for an example.
  3. In the Package Explorer, right click on invariants.json, and select 'Test Rep Invariants > Build Testable Code'
  4. In your unit tests, replace e.g. "new Foo()" with "new ExposedFoo()". There's also a menu option to do it automatically, but it's a little overzealous :)
  5. Run the tests as you normally would. If an invariant fails to hold, the thrown exception will tell you which one it was, and the stack trace will tell you exactly when (which method, and whether it was before or after).
  6. Debug!

Related

Wiki: Invariants file format

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.