[arquillian-issues] [JBoss JIRA] (ARQ-1963) Original exception lost when thrown from @Before-annotated method

Christian Schulz (JIRA) issues at jboss.org
Thu Jul 9 05:19:04 EDT 2015


Christian Schulz created ARQ-1963:
-------------------------------------

             Summary: Original exception lost when thrown from @Before-annotated method
                 Key: ARQ-1963
                 URL: https://issues.jboss.org/browse/ARQ-1963
             Project: Arquillian
          Issue Type: Bug
          Components: Base Implementation
            Reporter: Christian Schulz


I have recognized that there seems to be an issue with JUnit and Arquillian.

If there is an exception in @before-annotated method, it seems to be lost. There is no entry in the log neither the test will be aborted instantly.
{code}
    @Before
    public void preparePersistenceTest() {
        throw new RuntimeException("test");
{code}

A NPE occurs in @after-annotated method. The @test-annotated method doesn't fail fast.

Here the console output:
{code}
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.979 sec <<< FAILURE! - in RelocateTest
relocateSuccessful(RelocateTest)  Time elapsed: 0.24
1 sec  <<< ERROR!
java.lang.NullPointerException: null
        at RelocateTest.clearData(PackageRelocateTest.java:77)
{code}


*The issue*
testFailure in ExpectedExceptionHolder is notified and overwrite an existing exception https://github.com/arquillian/arquillian-core/blob/e39433696861f11588180894378c32f795da8085/junit/container/src/main/java/org/jboss/arquillian/junit/container/JUnitTestRunner.java#L110

This exception is used to create the testresult:
https://github.com/arquillian/arquillian-core/blob/e39433696861f11588180894378c32f795da8085/junit/container/src/main/java/org/jboss/arquillian/junit/container/JUnitTestRunner.java#L70

In my opinion there are two ways to handle this issue:

- Don't overwrite an existing exception and discard the new exception
- Change the TestResult class to hold multiple exceptions

The first approach could be implemented very fast. I can't imagine a case when other exceptions are really needed. I would say other exceptions occur because the first exception occurred.

https://github.com/arquillian/arquillian-core/issues/86



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the arquillian-issues mailing list