[Proj4j] JUnit: Capturing Test Results

Sunburned Surveyor sunburned.surveyor at gmail.com
Mon Nov 23 13:07:49 EST 2009


Martin,

I spent the last few days fiddling with JUnit, trying to figure out a
way to past supplemental data on test failures to the framework in a
way that is usable to programmers.

There are two (2) basic ways to do this. In the first way we implement
a custom RunListener and register it as a listener for test failures
with the JUnit core that runs the tests. If we use this method we can
automatically display a simple GUI that allows programmers to view
supplemental data on test failures. However, this method means we
can't run our tests via Eclipse, because we have to register the
RunListener implementation programatically, or basically in our own
main method.

In the second way we simply pass test data to a custom class that
writes the failure data to a text file. We then manually open a GUI
that reads and presents the data in the test file. This technique
allows us to continue running our tests form Eclipse, but requires a
couple of extra steps.

I've completed a partial implementation of the first technique I
described, and I have created shells for the second technique. I think
we might use both in Proj4J. I know I will use the second technique
while developing in Eclipse. The second technique can be used as part
of our build process when tests are executed outside of Eclipse.

I'm packaging the code for both techniques in the
net.surveyos.sourceforge.utilities.testing.junit package on my
SurveyOS SourceForge SVN. (The whole shebang will only be about 3 or 4
classes.)

I'll try to have something that works this week. The solution isn't
ideal, but it is probably as good as it gets until they makes some
changes to JUnit/Eclipse so extensions to the framework can be loaded
automatically.

I admittedly got a little sidetracked with this, so I am going to try
to wrap it with a simple (but imprefect) solution. Still, it is better
than System.err.println statements.

Landon


More information about the Proj4j mailing list