I Had a Dream

Ok, actually I hadn’t. I woke up 3:00 AM with an idea in my mind, which kept me from sleeping the rest of the night. That’s why I’m so tired right now. But here comes the idea:

JUnit tests in Mauve

I imagine to implement the JUnit API in a way that makes all JUnit tests automagically a Mauve test. This seems quite easy, junit.framework.TestCase would implement the TestHarness interface and the test(TestHarness) method would call into the runTest() (or similar) method to actually run the JUnit tests. The JUnit assertions are then delegated to the Mauve TestHarness object. That should be fairly easy and enable the following:

  • Integration of existing JUnit tests (Harmony testsuite) by simply adding the JAR to the classpath and calling java Harness . The output would come in the Mauve style that you’re used to.
  • Implement new Mauve tests in the form of a JUnit test. This has a couple of advantages obviously, like having the setUp() and tearDown() methods called before/after each test, automatically test all test*() methods, setting the checkPoint for these test*() methods etc.

Mauve in JUnit

A similar concept could be implemented in the other direction. In order to have Mauve running a JUnit test runner, we would need a subclass of junit.framework.TestSuite, that loads and runs a set of Mauve tests, and generates a TestHarness for them, that calls into the JUnit assert*() methods. The set of Mauve tests to be run could be fetched from a system property or a configuration file, or maybe from the commandline like it’s done now in the Harness class. This would enable us to:

  • Run Mauve conveniently inside IDEs that support JUnit.
  • Generate test reports using tools written for JUnit.

I am hacking on the first idea right now and hope to show a working prototype soon.


About Roman Kennke
JVM Hacker, Principal Software Engineer at Red Hat's OpenJDK team, Shenandoah GC project lead, Java Champion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: