TestNG is Test execution framework. it allows a developer or Test Automation engineer to control their test flows with a wide range of options. TestNG has a lot of features which are more test automation oriented. We will look at all of them in different posts.
To Start With, first of all, we will configure the TestNG in Eclipse and create a basic TestNG Test class.
Step 1: Installation
TestNG can be installed in two ways:
- Installing TestNG Plugin in Eclipse
- Adding the TestNG jar file in the project
Installing TestNG Plugin in Eclipse:
Step1 : Go to Help Menu > Select Eclipse Marketplace:
Step 2: Type “TestNG” in Find Textbox and hit the enter key
Click on Install and follow the installation Wizard. you will able to install the TestNG
Adding the TestNG jar file in the project
If you are using Maven, Add following maven dependency in POM file.
<!-- --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.14.3</version> <scope>test</scope> </dependency>
if you are not using maven then download the TestNG file from HERE
add the downloaded jar file into your project.
Step 2: Create a TestNG Class
Now create the class named “Hello” and paste the below code:
package TestNG; // replace this with you package name import org.testng.annotations.Test; public class Hello { @Test public void f() { System.out.println("Hello Qeworks"); } }
Step 3: Run the class as TestNG Test
you will get following output on the console:
[RemoteTestNG] detected TestNG version 6.14.3 Hello Qeworks PASSED: f =============================================== Default test Tests run: 1, Failures: 0, Skips: 0 =============================================== =============================================== Default suite Total tests run: 1, Failures: 0, Skips: 0 ===============================================
in Eclipse it will look like this:
you are able to get this result, it means you have successfully configured the TestNG.