Wednesday, October 2, 2013

Generate ReportNG report using Maven

Earlier I had covered in my blog about generating TestNg-xslt report for your TestNG test execution using Maven. Following is the link to it:


In this blog I will write about how to generate a ReportNG report for your TestNG test execution using maven. Following is a pom.xml file that can be used to execute your tests in a maven project and also generate a ReportNG report after execution.


 4.0.0
 com.test.maven
 sample-maven-build
 1
 sample-maven-build
 
  
  src
  
   
   
    org.apache.maven.plugins
    maven-surefire-plugin
    2.14.1
    
     
     
      testng.xml
     
     
     
     
         
           listener
           org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter
         
     
    
   
   
    maven-compiler-plugin
    
      1.7 
     1.7
    
   
  
 
 
  
  
   com.google.inject
   guice
   3.0
   test
  
  
   org.uncommons
   reportng
   1.1.4
  
  
   org.testng
   testng
   6.3.1
  
 



Run the following command to run your test cases and generate the ReportNG report.

mvn clean test

Or just

mvn test

Once run by default the execution report can be found under the folder named "html" under the surefire report directory inside "target" folder of your project folder.

14 comments:

  1. Thanks Varun for the post, but I am not able to generate XSLT reports . Below pom only gives reportng reports: Please let me know whats wrong in it:
    I have tried :
    mvn clean test
    mvn test
    mvn clean and then mvn test but it didnt give xslt report in the HTML folder.

    4.0.0

    com.delete_xslt
    creams
    0.0.1-SNAPSHOT
    jar

    creams
    http://maven.apache.org



    src/test/resource

    **/*.java










    org.apache.maven.plugins
    maven-surefire-plugin
    2.14.1





    listener

    org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter



    target/



    maven-compiler-plugin
    2.3.2

    1.7
    1.7













    com.google.inject
    guice
    3.0
    test


    org.uncommons
    reportng
    1.1.4


    org.seleniumhq.selenium
    selenium-java
    2.34.0


    org.seleniumhq.selenium
    selenium-support
    2.34.0



    org.seleniumhq.selenium
    selenium-api
    2.34.0


    org.testng
    testng
    6.8.5




    How you are able to write nice posts ob this page but our reply looks very bad?

    ReplyDelete
    Replies
    1. The combined pom.xml file is available at following location:

      https://gist.github.com/menonvarun/6865213

      Delete
  2. You can use gist to provide link your code snippets.

    ReplyDelete
  3. I dont know what it is and how to use it with this page... :)

    ReplyDelete
    Replies
    1. Gist is a simple way to share your code snippets with others. You add a code and give it a description and name. Gist will give you a url which you share with others ans they can refer to it. In this case your pom.xml.

      Gist url is:
      https://gist.github.com/

      Anyways I had written a combined pom xml for both reportng and testng xslt which i had shared in my earlier comment in this post.

      Delete
  4. great work Varun. It helped me a lot.

    ReplyDelete
  5. Hi Varun can you check for this please "ArtifactTransferException: Failure to transfer velocity:velocity-dep:jar:1.4 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact velocity:velocity-dep:jar:1.4 from/to central (http://repo.maven.apache.org/maven2): No response received after 60000"

    ReplyDelete
  6. Hi Varun,

    I have a requirement where i need to generate testng xslt report from junit code using maven. Can you please let me know the plugins to use and the code to execute the same?

    ReplyDelete
    Replies
    1. This comment has been removed by a blog administrator.

      Delete
  7. @Mannat, there is only one way to use "ant run" plugin in pom.xml and call your build.xml. Else there is no way to do it.

    ReplyDelete
  8. Hi Paul,

    Thanks for your reply. I am completely new to maven and ant. Could you help me if i provide my pom.xml? As my application is using maven only as the build tool

    ReplyDelete
    Replies
    1. This comment has been removed by a blog administrator.

      Delete
  9. I can but I dont want to :D
    Because its really simple stuff that you can achieve just by spending some time. If not then search on google you will find it, or put it on forums like stackoverflow, google etc.

    ReplyDelete