添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
暴走的海龟  ·  easyui ...·  1 年前    · 
强健的鸭蛋  ·  sap abap selection ...·  1 年前    · 
八块腹肌的盒饭  ·  旭日图(sunburst ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

my tests are run by surefire plug-in. In case test failed I get the following output:

Results :
Failed tests: 
  test1(com.my.MyClassTest)
Tests run: 3, Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
Please refer to /home/user/myproject/mymodule/target/surefire-reports for the individual test results.

To get the details about the problem I have to go and check surefire reports folder. Doing this every time my tests fail becomes annoying. Is there any way I can get those details (assert message + exception + stack trace) right here on the stdout ?

I find there's way too much output produced on stdout to be useful. Try leaving the HTML report open in your browser. After running your tests just refresh the page. Have a look at target/surefire-reports/index.html.

To output test results to stdout rather than a file use the following command:

mvn test -Dsurefire.useFile=false

Or to configure in your pom.xml add the following to your plugins section.

<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.10</version>
  <configuration>
    <useFile>false</useFile>
  </configuration>
</plugin>
                Thanks! Missed that option. So the only thing which is being output to console instead of file is that brief report, while all the other staff like xml, html reports are still being produced?
– pavel_kazlou
                Nov 18, 2011 at 10:48
                Yes. So you have your assertion message, exception message and stack trace right there on stdout.
– orien
                Nov 18, 2011 at 11:05
                That command doesn't seem to always work for me... it worked the first time, I fixed the issues, I hit the up arrow and ran it again, but the next time I spat out a message about needing to check target/surefire-reports again, without the contents of the file.
– ArtOfWarfare
                Oct 21, 2013 at 14:22

It's possible you may be using an older version of Surefire. I have found that newer versions produce more useful output on the console.

If you only want to see failing tests or tests with errors and only see errors in the build, you can pass the -q argument to your Maven build command.

please check your version of jacoco plugin is compatible with jdk or not: i was getting similar issue , test cases were passing but it was failing while building project. so upgraded version worked for me:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.4</version>
    <executions>
        <execution>
            <id>jacoco-initialize</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>jacoco-site</id>
            <phase>package</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
</plugin>
                As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
– Community
                Dec 16, 2022 at 6:10
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.