Lifecycle Methods
Lifecycle Methods ~30 mins

TestNG - Lifecycle Methods

	package testng.day1;

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

public class BaseClass {

@BeforeMethod
public void beforeMethod() {
System.out.println("beforeMethod");
}

@AfterMethod
public void afterMethod() {
System.out.println("afterMethod");
}

@BeforeClass
public void beforeClass() {
System.out.println("beforeClass");
}

@AfterClass
public void afterClass() {
System.out.println("afterClass");
}

@BeforeTest
public void beforeTest() {
System.out.println("beforeTest");
}

@AfterTest
public void afterTest() {
System.out.println("afterTest");
}

@BeforeSuite
public void beforeSuite() {
System.out.println("beforeSuite");
}

@AfterSuite
public void afterSuite() {
System.out.println("afterSuite");
}

}
	package testng.day1;

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

public class LeafTapsTestCases extends BaseClass{

@Test
public void test1() {

System.out.println("test1");

}
}
	package testng.day1;

import org.testng.annotations.Test;

public class LearnAttributes {

@Test(priority = -1)
public void createLead() {
System.out.println("Create Lead");

}

@Test(priority = 1, enabled=false)
public void editLead() {
System.out.println("Edit Lead");

}

@Test(priority = 2)
public void deleteLead() {
System.out.println("Delete Lead");

}
}
	package testng.day1;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class LTTestCase extends BaseClass{

@Test
public void test2() {

System.out.println("test2");

}

@BeforeMethod
public void preCondition() {
System.out.println("preCondition");

}

}