TestNG Launcher (testng.jar)

The TestNG launcher allows interfacing with TestNG tests.
It has been tested with TestNG 5.10


Configuration

The testng.xml file allows pre-configuring the launcher with some default values:

Parameter Description
General > Test root path This must indicate where are located all the TestNG tests. This is a root path. Each test in XStudio has a canonical path that will be appended to this path.
This path MUST not include an ending slash.

Default value is: C:/Program Files/testng-5.10/examples/src
General > Additional classpath This must indicate potential additional jar classpath necessary to test the SUT. This can contain several path separated by ‘;’.

Default value is:
TestNG > Java install path This must indicate the path to the java install.

Default value is: C:/Program Files/Java/jdk1.6.0_06
TestNG > TestNG jar path This must indicate the path to the TestNG library.

Default value is:
C:/Program Files/testng-5.10/testng-5.10-jdk15.jar


These values can be changed while creating the campaign session from XStudio.


Requirements

The tests are executed by the launcher using this syntax:

<javaInstallPath>/bin/java.exe –classpath <testNGJarPath> ;<additionalClassPath> ;<testRootPath> org.testng.TestNG –testclass <testPath>.<testName>

And this is executed from the working directory <testRootPath>

The test will be marked as passed or failed depending on the xml log file generated by TestNG. The xml file is parsed by the launcher. The logs, HTML reports and the execution trace of the command are also attached to the testcase execution in XStudio.


Tutorial: Creating and executing TestNG tests

In this tutorial, we will learn to run some TestNG tests. We will use TestNG 5.10 but this can be applied to any version of TestNG. As an example, we will execute a sample test provided with TestNG 5.10: Test1


Prerequisites

Install TestNG 5.10 in the folder C:Program Files testng-5.10
The sample test is provided as source file only, so we need to compile it first. To do so run the following commands:

cd C:/Program Files/testing-5-10/examples
"C:/Program Files/Java/jdk1.6.0_02/bin/javac.exe" -classpath "C:/Program Files/testing-5-10/testng-5.10-jdk15.jar” src/example1/Test1.java


This will compile and create the file:
C:/Program Files/testing-5-10/examples/src/example1/Test1.class


Create a dedicated category for TestNG tests and create a test

  • create a category TestNG associated to the launcher testng.jar
  • under this category, create (somewhere in the tree) the test with the name Test1, and a canonical path set to example1.



Creating a test campaign

  • create a campaign including the test Test1.
  • create a campaign session with the default configuration settings.


Run a campaign session

Run the campaign session