junit-nested: TestRunner for non-static inner classes

"Aaron V." <[email protected]> Wed, 14 Aug 2013 04:53:00 -0000
Newsgroups gmane.comp.java.junit.user
Message-ID <[email protected]>
I'm announcing the 1.0 release of junit-nested, a TestRunner that allows test classes to contain non-static inner classes which also have test methods.  Inner test classes can be nested to arbitrary depth, and @Before and @After methods and @Rules will be run at all levels--that is, tests in inner classes will get the benefit of befores and afters in their parent (and grandparent, etc) classes.

Of course, whether or not you _should_ make use of nested tests I find is a matter of debate, but nonetheless it's a useful tool to have at your disposal (and rspec (ruby), Cedar (obj-c) and jasmine (javascript) all promote nested test structures).


Source code (and an example) is available https://github.com/avh4/junit-nested and the jar is available on maven central as net.avh4.test:junit-nested:1.0.1

It is currently licensed under the EPL.  If you have need of a different license, please contact me.

Also, if anyone with more knowledge of the internals of BlockJUnit4ClassRunner can make any suggestions on improving my attempts to extend it, I would appreciate the feedback.
https://github.com/avh4/junit-nested/blob/master/src/main/java/net/avh4/test/junit/InnerRunner.java

Cheers,
--Aaron V.