Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
5.1k views
by Expert (572 points)

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 like 0 dislike
by The go-to Tester (181 points)
selected by
 
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

 


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...