Unit Test History and Import Export in Eclipse

Having spent several weeks working with a suite of integration tests that take an extremely long time to complete, few things can be as annoying as the following scenario:

  • Run a suite of tests, some of them fail
  • Double-click the failed test, to inspect the code
  • Modify the code in that test, rerun just that test
  • Test passes, now I want to go on to the next failing test, but oohhh, your list of failed tests are gone

I’d classify this as an Eclipse UI design failure, but there are several solutions to this sticky situation. The most naive is to simply rerun all the tests, but I really don’t want to do that. The next best option is to, before digging into the failures, to copy the JUnit console output and stack traces into a text editor. Either manually or through some creative regular expressions, you can be left with just a list of the ClassName.MethodNames of the failing tests.

The proper solution is to use the JUnit tab’s Test History menu to rerun or simply view old test runs.

The test history drop-down gives you the option to rerun the last 10 or so tests, but that’s not really what we want. If you explore the History dialog from this menu, you will have access to the results from previous JUnit test executions (default is configured to store the last 99 test runs).

This is great, but keep in mind that it is cleared every time eclipse shuts down. To address this, there is a handy XML Import/Export feature that allows you to your Test History to an XML file, and load that XML file back again at a later time. So, run your expensive test, and before hacking away at all those broken tests you could have sworn you fixed, export your test results for handy lookup!

It's only fair to share...
Share on Facebook
Tweet about this on Twitter
Share on LinkedIn

Leave a Reply