maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Johnston (Jira)" <j...@apache.org>
Subject [jira] [Commented] (SUREFIRE-1748) JUnit 5 Assertions.fail() breaks reporting
Date Mon, 03 Feb 2020 21:36:00 GMT

    [ https://issues.apache.org/jira/browse/SUREFIRE-1748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17029311#comment-17029311
] 

Albert Johnston commented on SUREFIRE-1748:
-------------------------------------------

Yes, it's the same line.

[https://github.com/apache/maven-surefire/blob/master/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java#L398]

The line is:
{code:java}
failure( "  " + testMethodStats.get( 0 ).getStackTraceWriter().smartTrimmedStackTrace() );
{code}
I've already looked into this a couple times, once for a few minutes to see if it was a simple
fix, and a second time for an hour or so to really dig around for the issue. I can say with
certainty that the returned null value is the
{code:java}
getStackTraceWriter(){code}
causing the NPE when 
{code:java}
smartTrimmedStackTrace(){code}
is called. Although I'm not at all familiar with this part of the project, I'm inclined to
believe that the issue isn't here. Especially considering the fact that this issue doesn't
happen with JUnit4's Assert.fail(), even if you explicitly pass in null. I think it's likely
that there's a check somewhere else that's treating JUnit 5's assert differently, but it's
really just conjecture. I even tried manually changing a few of those places to return a non-null
value, but nothing helped. I was focusing on this in particular at one point, but again, didn't
help:

[https://github.com/apache/maven-surefire/blob/master/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java#L133]

 

I'll give it another shot tonight, it's been a few days, maybe coming at it fresh will help.
Also, if you have any thoughts, I'm open to ideas.

> JUnit 5 Assertions.fail() breaks reporting
> ------------------------------------------
>
>                 Key: SUREFIRE-1748
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1748
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: JUnit 5.x support, Maven Surefire Plugin
>    Affects Versions: 3.0.0-M4
>            Reporter: Albert Johnston
>            Priority: Major
>
> Associated versions on my end at time of testing:
>  * JUnit Jupiter 5.3.2
>  * JDK 1.8u172
>  * Maven 3.6.3
> Demonstration available at [https://github.com/ajohnstonTE/surefire-jira-examples/tree/master/junit-assertions-fail]
> If the following JUnit 5 code is run through Surefire, then the reporting breaks for
that class, resulting in no reported errors/failures from that class (though any failures
will still be reported overall in the counts):
> {code:java}
> public class JUnit5Test {
>   @Test
>   void failWithNoParameters() {
>     Assertions.fail();
>   } 
> }
> {code}
> Resulting output:
>  
> {noformat}
> [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 s <<<
FAILURE! - in JUnit5Test
> [ERROR] JUnit5Test.failWithNoParameters  Time elapsed: 0.008 s  <<< FAILURE!
> [ERROR] Failures:
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test
(default-test) on project junit-assertions-fail: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test
failed.: NullPointerException -> [Help 1]
> [ERROR]
> [ERROR] To see the full stack trace...{noformat}
> And with the -e flag, trimmed to the relevant part:
>  
> {noformat}
> [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 s <<<
FAILURE! - in JUnit5Test
> [ERROR] JUnit5Test.failWithNoParameters  Time elapsed: 0.007 s  <<< FAILURE!
> [ERROR] Failures:
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test
(default-test) on project junit-assertions-fail: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test
failed.: NullPointerException -> [Help 1]
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test
(default-test) on project junit-assertions-fail: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test
failed.
> Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-test of
goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test failed.
> Caused by: java.lang.NullPointerException
>     at org.apache.maven.plugin.surefire.report.DefaultReporterFactory.printTestFailures
(DefaultReporterFactory.java:398)
>     at org.apache.maven.plugin.surefire.report.DefaultReporterFactory.runCompleted (DefaultReporterFactory.java:198)
>     at org.apache.maven.plugin.surefire.report.DefaultReporterFactory.close (DefaultReporterFactory.java:171)
>     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run (ForkStarter.java:254)
>     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider (AbstractSurefireMojo.java:1217)
>     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked
(AbstractSurefireMojo.java:1063)
>     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:889){noformat}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message