Re: junit-nested: TestRunner for non-static inner classes
Aaron VonderHaar <[email protected]> Thu, 15 Aug 2013 19:05:07 -0700
| Newsgroups | gmane.comp.java.junit.user |
|---|---|
| Message-ID | <CAMZecX=rw11EXANV+k6855RZpezAZbk8Lwk+CVA61F1yrUNHBA@mail.gmail.com> |
Cool, I did take a look at specsy before I started Nested, but I didn't want to use anonymous classes for each test, and I'm not quite ready to commit to JDK 8 or scala/groovy yet. As for test isolation, currently each each inner class instance gets its own independent outer class instance, so everything should be completely isolated. On Wed, Aug 14, 2013 at 6:23 AM, Esko Luontola <[email protected]>wrote: > ** > > > As they say, great minds think alike. :) Some years ago I wrote a similar > thing, even named it almost the same: > https://github.com/orfjackal/nestedjunit If yours supports arbitrary > depth, > then that's more than nestedjunit does (it supports only max 2 levels of > tests). Is the test isolation also the same? > > I got used to that style of organizing tests when learning TDD and writing > tests with JDave. I've found 1-2 levels is nearly always enough, though I > appreaciate the flexibility of arbitrary depth. For other JVM languages, > and Java with lambda expressions, I've written an even more flexible > testing framework: http://specsy.org/ You might like it, so have a look. > (It requires the http://jumi.fi/ test runner, which is still lacking in > tool support, so that's a negative side, for now.) > > On Wed, Aug 14, 2013 at 7:53 AM, Aaron V. <[email protected]> wrote: > > > ** > > > > > > > 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. > > > > > > [Non-text portions of this message have been removed] > > > -- --Aaron V. [ http://github.com/avh4 ] [Non-text portions of this message have been removed]