Loading ...
Sorry, an error occurred while loading the content.

Re: [junit] junit-nested: TestRunner for non-static inner classes

Expand Messages
  • Esko Luontola
    ... Yeah, that s understandable. JDK 8 is still at beta and changing the language can be a big change. In some projects I m using
    Message 1 of 4 , Aug 16 2:35 AM
      Aaron VonderHaar wrote on 16.8.2013 5:05:
      > 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.

      Yeah, that's understandable. JDK 8 is still at beta and changing the
      language can be a big change.

      In some projects I'm using https://github.com/orfjackal/retrolambda to
      get lambda expressions on Java 7. I compile the source with JDK 8 and
      then use Retrolambda to convert the lambdas into regular anonymous
      clases, so that they will run on earlier JREs.

      > As for test isolation, currently each each inner class instance gets its
      > own independent outer class instance, so everything should be completely
      > isolated.

      Good. That's the way I like it and how JUnit does it. TestNG users may
      disagree. ;) For some reason not all understand it:

      I have one idea that how to implement a shared instance for all test
      methods, without violating the default test isolation. The test class
      could take as constructor parameter an object, which the test runner
      will instantiate only once and pass the same instance to all test class
      instances. Then that injected object could be used to hold shared state
      (e.g. database connection) without having to use static fields.

      I'm planning to implement that in Specsy. Already now it should be
      possible to implement it at the level of one test class, but in the
      future I'll improve Jumi to support implementing that at the level of
      _all_ test classes in the suite. I'll make it so that only one Driver
      [1] instance (it corresponds JUnit's Runner class) is created and it
      will be used for all test classes. Also the Driver will receive an event
      when the suite is finished (for teardown of the shared state).

      [1] http://jumi.fi/api/jumi-api/fi/jumi/api/drivers/Driver.html

      Esko Luontola
    Your message has been successfully submitted and would be delivered to recipients shortly.