Possible ConcJUnit Enhancement

I’m writing a paper about ConcJUnit, this time with an educational focus, and as usual, writing helps me in systematically covering the problem space. I shouldn’t spend a whole lot of time blogging now, because the paper submission deadline is approaching fast, but I want to make a more-than-just-mental note anyway.

ConcJUnit can emit “lucky” warnings if all child threads terminated before a test ended, but this was not enforced with a join. Daemon threads are exempt from this requirement, because they should shut down by themselves in a real program.

Now, what happens if I refactor my program and change something like this


public void someOperation() {
// ...
fail();
}

public void testFoo() {
new Thread() {
public void run() { someOperation(); }
}.start();
}

which will correctly warn me that the new thread wasn’t joined, into something like this:


public void testFoo() {
EventQueue.invokeLater(new Runnable() {
public void run() { someOperation(); }
});
}

This code puts the task on the event queue, but because the event thread is a daemon thread, ConcJUnit does not warn that the operation may not have had time to fail yet.

Perhaps I can enqueue a “token” event at the end of a test and wait for it to be processed?

Share

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. Bookmark the permalink.

Leave a Reply