Implementing TestNG

The previous procedurecheck involved setting up Eclipse for Selenium and run a chromedriver script. We now want to add test script capabilities. TestNG is a testing framework written in Java.


Eclipse IDE for Java DevelopersVersion: Oxygen.2 Release (4.7.2)
Build id: 20171218-0600

In Powershell:

java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

Download TestNG

In eclipse >> help >> install new software >> work with >> select repository: ngtest

then check TestNG and continue:

install details:

testng -

Guava: Google Core Librsries for Java v 15
TestNG version 6.13
TestNG M2E (Maven integration) version 6.13
TestNG P2 Feature v 6.13

next add as library: package >> properties >> Java build path >> Libraries >> add library >> add TestNG

This action will add a new set of TestNG jar files in a TestNG folder at the same level as the Referenced Libraries.

Activate TestNG

You can still run the script as a regular script (run) but we want to run as TestNG. In de runĀ  as dropdown the TestNG option is not visible. To solve this:

run >> run configurations >> TestNG is listed but not active >> right-click >> New

The testscript has some changes, the main() method with arguments yields errors and therefore replaced with doTest(). The @Test annotation is mandatory.

package com.assessmentee.tests;

import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;

public class AssessmenteeTest {

  public static void doTest() throws InterruptedException {
  WebDriver driver = new ChromeDriver();

The script can be run as TestNG test. The output to the console is

PASSED: doTest

 Default test
 Tests run: 1, Failures: 0, Skips: 0

Default suite
Total tests run: 1, Failures: 0, Skips: 0

In the test-output folder the testng-results.xml file also holds the results.