TestNG Annotations

This video will describe all Annotaions present in TestNG.






File 1


package LearningTestNG;

import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class TestNGAnotation_1 {

@BeforeClass
public void beforeClass(){
System.out.println("Initialize Selenium for Class 1");
}
@BeforeMethod
public void beforeMethod(){
System.out.println("Opening Browser");
}
@Test
public void test1(){
System.out.println("Inside Test 1");
}
@Test
public void test2(){
System.out.println("Inside Test 2");
}
@AfterMethod
public void afterMethod(){
System.out.println("Closing Browser");
}
@AfterClass
public void afterClass(){
System.out.println("Destroy Selenium for class 1");
}
}


File 2

package LearningTestNG;

import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class TestNGAnotation_2 {

@BeforeSuite
public void beforeSuite(){
System.out.println("Starting TestNG");
}
@AfterSuite
public void afterSuite(){
System.out.println("Stoping TestNG");
}
@BeforeTest
public void beforeTest(){
System.out.println("Start Test Execution");
}
@BeforeClass
public void beforeClass(){
System.out.println("Initialize Selenium for Class 2");
}
@Test
public void test3(){
System.out.println("Inside Test 3");
}
@AfterClass
public void afterClass(){
System.out.println("Destroy Selenium for class 2");
}
@AfterTest
public void afterTest(){
System.out.println("Stop Test Execution");
}
}



1 comment:

  1. Selenium WebDriver fits in the same role as RC did, and has incorporated the original 1.x bindings. It refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just "WebDriver" or sometimes as Selenium 2.
    Selenium Training Institute in Chennai

    ReplyDelete