Hey peepz, how are you? I have a question regardi...
# getting-started
d
Hey peepz, how are you? I have a question regarding Tests,
@Nested
,
inner
classes,
ParametrizedTests + MethodSource
I have the following
Copy code
class MyServiceTest {
   data class TestData(...)

   @Nested
   inner class MyServiceSpecific{
      private fun prepareTestData() = Stream.of(...)

      @ParameterizedTest
      @MethodSource("prepareTestData")
      fun `GIVEN this example WHEN executing test THEN should run`(data: Testdata) {
         // EVERYTHING I WANT TO TEST
      }
   }
}
With this structure I get the following error
Copy code
Cannot invoke non-static method [private final java.util.stream.Stream... on a null target.
How can I gave all this working, I am missing a glue probably
I found the solution I need to tell JUnit that needs to create my inner class using
Copy code
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
But I thought that Nested annotation were doing that already from the enclosing class
b
Have you tried removing the
inner
keyword?
d
According to @Nested documentation says that it should be a non static class, and inner do that for you