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

Peter Wessels edited comment on SUREFIRE-1887 at 10/29/22 11:01 AM:
--------------------------------------------------------------------

After some investigation, we found that 
[trimStackTrace|https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#trimStackTrace]
 can be used to shorten the stacktrace.

The implementation of this feature however, trims too much lines. To be 
valuable for users, the lines from the cause of the failure to the testcase are 
relevant.

Example:
trimStackTrace=true
!image-2022-10-29-12-56-00-008.png|width=595,height=67! 
trimStackTrace=false
!image-2022-10-29-12-56-10-482.png|width=1084,height=779!

We propose to change the implementation of this feature to include more 
relevant lines and make enable this option by default.

Our premature implementation generates the following stacktrace:

!image-2022-10-29-13-01-36-151.png|width=586,height=97!

We included our minimal test project.


was (Author: JIRAUSER297668):
After some investigation, we found that 
[trimStackTrace|https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#trimStackTrace]
 can be used to shorten the stacktrace.

The implementation of this feature however, trims too much lines. To be 
valuable for users, the lines from the cause of the failure to the testcase are 
relevant.

Example:
trimStackTrace=true
!image-2022-10-29-12-56-00-008.png! 
trimStackTrace=false
!image-2022-10-29-12-56-10-482.png!

We propose to change the implementation of this feature to include more 
relevant lines and make enable this option by default.

Our premature implementation generates the following stacktrace:

!image-2022-10-29-12-57-02-825.png!

We included our minimal test project.

> Test Failures should not dump stack. 
> -------------------------------------
>
>                 Key: SUREFIRE-1887
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1887
>             Project: Maven Surefire
>          Issue Type: Bug
>            Reporter: Elliotte Rusty Harold
>            Assignee: Maarten Mulders
>            Priority: Major
>         Attachments: image-2022-10-29-12-56-00-008.png, 
> image-2022-10-29-12-56-10-482.png, image-2022-10-29-12-57-02-825.png, 
> image-2022-10-29-13-01-36-151.png, maven-surefire-test-project.zip
>
>
> Typical failing test output from the Maven surefire plugin dumps a lot of 
> internal state. This is incorrect.
>  
> The purpose of the surefire plugin is to run the user's tests. These tests 
> are expected to fail much of the time. This a normal state. The test failure 
> should be reported, but this is in no way a failure of surefire itself. There 
> is no reason surefire should print its own stack. Indeed, this simply 
> obscures the real failure in the user's own code.
>  
> ```
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute 
> goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test 
> (default-test) on project dependencies: There are test failures.
> Please refer to 
> /home/runner/work/cloud-opensource-java/cloud-opensource-java/dependencies/target/surefire-reports
>  for the individual test results.
> Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump 
> and [date].dumpstream.
>  at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:215)
>  at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:156)
>  at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:148)
>  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
> (LifecycleModuleBuilder.java:117)
>  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
> (LifecycleModuleBuilder.java:81)
>  at 
> org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
>  (SingleThreadedBuilder.java:56)
>  at org.apache.maven.lifecycle.internal.LifecycleStarter.execute 
> (LifecycleStarter.java:128)
>  at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
>  at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
>  at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
>  at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
>  at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
>  at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>  at sun.reflect.NativeMethodAccessorImpl.invoke 
> (NativeMethodAccessorImpl.java:62)
>  at sun.reflect.DelegatingMethodAccessorImpl.invoke 
> (DelegatingMethodAccessorImpl.java:43)
>  at java.lang.reflect.Method.invoke (Method.java:498)
>  at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced 
> (Launcher.java:289)
>  at org.codehaus.plexus.classworlds.launcher.Launcher.launch 
> (Launcher.java:229)
>  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode 
> (Launcher.java:415)
>  at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
>  at sun.reflect.NativeMethodAccessorImpl.invoke 
> (NativeMethodAccessorImpl.java:62)
>  at sun.reflect.DelegatingMethodAccessorImpl.invoke 
> (DelegatingMethodAccessorImpl.java:43)
>  at java.lang.reflect.Method.invoke (Method.java:498)
>  at org.apache.maven.wrapper.BootstrapMainStarter.start 
> (BootstrapMainStarter.java:39)
>  at org.apache.maven.wrapper.WrapperExecutor.execute 
> (WrapperExecutor.java:122)
>  at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:61)
> Caused by: org.apache.maven.plugin.MojoFailureException: There are test 
> failures.
> ```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to