0
how to I generate report of my JUnit tests? I am using Maven and IntelliJ

Solved 1 Answers 9 Views

I am currently using JUnit4 with Maven in my project. I can execute my tests and all is going well. But, I am unable to see the report. What's wrong?

This is how my POM.xml file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>db-check</groupId>
    <artifactId>com.****</artifactId>
    <version>1.0</version>
    <dependencies>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.1.0.jre8</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.jexcelapi</groupId>
            <artifactId>jxl</artifactId>
            <version>2.6.12</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.esotericsoftware.yamlbeans/yamlbeans -->
        <dependency>
            <groupId>com.esotericsoftware.yamlbeans</groupId>
            <artifactId>yamlbeans</artifactId>
            <version>1.06</version>
        </dependency>

    </dependencies>
</project>

 

1 Answer

1
Best answer

You can generate this report by using maven-surefire-plugin.

You can include the plugin as below into your pom.xml file

<project>
  ...
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.5</version>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

It will generate .xml files. You can generate HTML report by executing

surefire-report:report

goal. 

Your maven code can be

mvn clean test surefire-report:report

Also, you can try 

<reportSets>
   <reportSet>
           <reports>
                 <report>report-only</report>
           </reports>
   </reportSet>
</reportSets>

as below:

<project>
  ...
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.5</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>report-only</report>
                        </reports>
                    </reportSet>
                </reportSets>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

You can execute it as below:

mvn clean test site

 

answered 6 days ago by stbadmin (4,747 points)
selected 6 days ago by SunilBhaskar

Kindly Register and join the community of software testing professionals.

Notice:

We have recently moved our Question and Answer site from the domain name www.MayurShah.in to https://softwaretestingboard.com/qna as per the feedback from visitors.

For complete history of major changes, you can go to History

Site Status

  • que
  • ans
  • com
  • ua
  • us
  • Questions 817
  • Answers 738
  • Comments 464
  • Unanswered 126
  • Unselected 414
...