How to execute Junit test and generate HTML result file just using one command line (use Maven surefire report Plugin)

1,340 views
Skip to first unread message

nguyen hung

unread,
Sep 3, 2014, 2:32:33 PM9/3/14
to maven-a...@googlegroups.com

Now, I'm able to get HTML result file from Maven Surefire Report Plugin, I have to execute 2 command lines:

  1. mvn test -Dtest=classname

  2. mvn surefire-report:report

Is there any solution to combine these two command lines into one command line? I just need to make a shorter way instead of executing 2 commands as now. 


Additionally, I cannot rename or change location for this HTML result file. Could you please shed me a light for that?

Below is my POM file:

<?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>com.mycompany</groupId>
    <artifactId>mavenproject1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.42.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>   
    <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.17</version>
        <configuration>
          <outputName>newname</outputName>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
</project>

Thanks

David Bernard

unread,
Sep 3, 2014, 2:52:24 PM9/3/14
to Maven and Scala
Have you try ?

    mvn test -Dtest=classname surefire-report:report


--

---
You received this message because you are subscribed to the Google Groups "Maven and Scala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maven-and-sca...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages