TestNG Practice 1

Step 1: Open Eclipse

Step 2: Create a java Project. Select File -> New ->Java Project


Step 3: Add a new package within the same class. Right-click on class ->Select New -> Select Package




Step 4: You need every time the main method while executing a program in java., means you are using java compiler to compile the code. But when you use TestNG you need not required java compiler. you can directly use execute program by creating a simple method and writing simple code.
As shown in below



  Here we use public as access specifier and void is a return type and TestNG1 is a class name


Step 5: Take the cursor on @Test and select the Add TestNG library.


Step 6: Take the cursor on @Test and select import ‘Test’(org.testng.annotations)


After writing @Test it treated as TestNG program even when not writing the main method


Step 7: Now for executing the program, right-click on the project and select Run As-> TestNG Test

Step 8: And you get the output in different formats. It contains Test case executed, pass cases and Fails cases and other important information