Unit Tests for Thread Checker

I’ve started writing unit tests for the thread checker. This turns out to be quite a difficult matter because so many things are involved:

  1. The source code needs to be compiled.
  2. The compiled classes need to be instrumented.
  3. The instrumented classes need to be examined and executed.

Additionally, checking correctness is complicated by these issues:

  • The checks may occur in any permutation, as long as all of them occur.
  • No additional checks may occur.

I wanted to be able to run the test programs independently, so I decided to include them as regular source files in the repository. The test cases require that the source was compiled and then copies the test classes to a temporary directory. There they are instrumented, analyzed and run. I analyze both the bytecode and the output of the log file.

So far I’ve written simple tests both for @NotRunBy and @OnlyRunBy, now I still have to write more complicated tests that involve inheritance and subtyping warnings.

I also just fixed another DrJava bug that involved regions in the Bookmarks panel not properly updating when the document was changed. This sounds very similar to another bug I had fixed earlier, where Find All results displayed the same behavior. Today I determined that both had the same cause: The regions only held integer offsets, not Positions that move within the document. Bookmark sections now update properly, but I left the fix for Find All results in place, so they’re still static. I like the idea that the results of Find All represent a “snapshot” of the program at the time of the search.


About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Concurrent Unit Testing, DrJava. Bookmark the permalink.

Leave a Reply