Bug report / Enhancement
Issue Overview
NPE is fired before @test method is executed in @nested class.
Expected Behaviour
NPE isn't throw and @test runs successfuly
Steps To Reproduce
@ExtendWith(ArquillianExtension.class)
@ArquillianSuiteDeployment
@Transactional(TransactionMode.ROLLBACK)
public abstract class ArquillianBasedTest {
private static final Logger LOG = LogManager.getLogger();
@EJB
private ServerStateService serverStateService;
@Inject
private IAppServerPathProvider appServerPathProvider;
@BeforeEach
protected void setUp() throws Exception {
waitForServer();
}
private void waitForServer() throws Exception {
org.awaitility.Awaitility.await().until(() -> ServerState.READY.equals(serverStateService.getServerState())); //here occured NPE as serverStateService is null
}
}
class TypeLevelReferenceDaoIntegrationTest extends ArquillianBasedTest {
@EJB
private ITypeLevelReferenceDao daoUnderTest;
@Test
void testFindTypeLevelReferenceByTypeElementPathViaReferenceTypeElement() {
//tests that are directly in class runs fine. All EJB, CDI fields are injected
}
@Nested
class NestedTest {
@Test
void testx() {
System.out.println("Hello world from nested test "); //this line is never invoked as first it run @BeforeEach and failed on NPE
}
}
When debug it:
- when it is "parent" test method then in org.jboss.arquillian.junit5.container.JUnitJupiterTestRunner.execute(Class<?>, String) testClass is TypeLevelReferenceDaoIntegrationTest
- org.jboss.arquillian.junit5.ArquillianExtension.interceptBeforeEachMethod(Invocation, ReflectiveInvocationContext, ExtensionContext)
- invocation delegate target is instance of testClass and has all fields correctly injected
- when it is nested case then testClass is TypeLevelReferenceDaoIntegrationTest$NestedTest
- invocation delegate target is integration.de.ids.acos.et.server.dao.ooe.type.TypeLevelReferenceDaoIntegrationTest@3d91b4a1 and all fields are null
the condition predicate says that it runs insideArquillian
TestMethodTestDescriptor: [engine:junit-jupiter]/[class:integration.de.ids.acos.et.server.dao.ooe.type.TypeLevelReferenceDaoIntegrationTest]/[nested-class:NestedTest]/[method:testx()]
testInstances are:
[integration.de.ids.acos.et.server.dao.ooe.type.TypeLevelReferenceDaoIntegrationTest@3d91b4a1, integration.de.ids.acos.et.server.dao.ooe.type.TypeLevelReferenceDaoIntegrationTest$NestedTest@5dcbafbe]
Bug report / Enhancement
Issue Overview
NPE is fired before @test method is executed in @nested class.
Expected Behaviour
NPE isn't throw and @test runs successfuly
Steps To Reproduce
When debug it:
the condition predicate says that it runs insideArquillian
TestMethodTestDescriptor: [engine:junit-jupiter]/[class:integration.de.ids.acos.et.server.dao.ooe.type.TypeLevelReferenceDaoIntegrationTest]/[nested-class:NestedTest]/[method:testx()]
testInstances are:
[integration.de.ids.acos.et.server.dao.ooe.type.TypeLevelReferenceDaoIntegrationTest@3d91b4a1, integration.de.ids.acos.et.server.dao.ooe.type.TypeLevelReferenceDaoIntegrationTest$NestedTest@5dcbafbe]