5

I have created a maven project for testing my application. I have used Webdriver, TestNG framework in my projet. I have used maven surefire plugin and reporty-ng plugin to generate report for the test cases. This works fine when I run within IDE ( eclipse ) or command prompt using command ( mvn test site). Now I have to make it a jar file, so that I can put that jar file in any system and run it.

So here the problem comes:

  1. Maven jar does not include test source and class available in src\test . we may solve this using test-jar goal of maven jar plugin
  2. Even anyhow I may create maven jar file, but how do I run it , because I do not have main class, I use testng.xml suite to run my test. I use testng.xml in configuration of surefire plugin

So how I will run the jar file ?

  • First you are doing integration tests which means you should use maven-failsafe-plugin instead of maven-surefire-plugin. Furthermore you can make a separate module which depends on the module which contains the app which should be tested. So you can do an test via `mvn verify`. [Here you find a description](http://khmarbaise.github.io/maui/it-example-container.html) and [here you can find a full example](https://github.com/khmarbaise/maui/tree/master/src/main/resources/it-example-container-selenium). – khmarbaise Oct 14 '13 at 07:54
  • My tests are running fine using surefire plugin. When I use mvn command to build the project and run the test , then everything runs fine. My problem is how I will make a jar file so that I can use it in different system. – MihirSasmal Oct 14 '13 at 08:01
  • I like this http://mojo.codehaus.org/appassembler/appassembler-maven-plugin/ – Franz Ebner Oct 14 '13 at 09:53
  • I don't have main class, So I don't think the above solution will help. – MihirSasmal Oct 14 '13 at 12:53

1 Answers1

0

I take it you want to have your tests run not only in maven, but also in some other build system (e.g., Ant) ?

If that is the case then I think what you want is some nice reports that tell you how your tests did. If so, you might want to look at this project: http://reportng.uncommons.org/

you need to create an ant classpath ref 'test-path' that includes your test jars (and the jars for the classes under test)... then you would do something like this

<testng classpathref="test-path" outputdir="${test-results.dir}" haltonfailure="true" useDefaultListeners="false" listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter"> <xmlfileset dir="." includes="testng.xml"/> <sysproperty key="org.uncommons.reportng.title" value="My Test Report"/> </testng>

Chris Bedford
  • 2,560
  • 3
  • 28
  • 60