Daniel Branco
09/12/2021, 5:40 PM@Nested
, inner
classes, ParametrizedTests + MethodSource
I have the following
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
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 probablyDaniel Branco
09/12/2021, 5:45 PM@TestInstance(TestInstance.Lifecycle.PER_CLASS)
But I thought that Nested annotation were doing that already from the enclosing classBenoît Liessens
09/13/2021, 3:36 AMinner
keyword?Daniel Branco
09/13/2021, 8:13 AM