1. @ test: basic annotation, to the marked part of the test method
2. @ BeforeMethod: method run before the test method
The method of operation after the test method: 3. @ AfterMethod
Code demonstrates:
Output:
4.BeforeClass: refers to a method for operating prior class runtime
5.AfterClass: refers to a method for operating after operation of the class
com.course.testng Package;
Import org.testng.annotations *;.
public class BasicAnnotation {
// basic annotations, the method used to mark part of the test
@Test
public TestCase1 void () {
System.out.println ( "test this is a test case. 1");
}
@Test
public void testCase2 () {
System.out.println ( "test this is a test case 2");
}
@BeforeMethod
public void beforeMethod () {
System.out.println ( "BeforeMethod this test was run before the method");
}
@AfterMethod
public void afterMethod () {
System.out.println ( "AfterMethod which is run after the test methods");
}
@BeforeClass
public void BeforeClass () {
System.out.println ( "Method beforeClass which is run before the class");
}
@AfterClass
public void AfterClass () {
System.out.println ( "AfterClass which is in the process of running after running class");
}
}
output:
6. BeforeSuite: Test Suite, method of operation, run before class:
7. AfterSuite: test suite, run after run class method
Code demonstrates:
com.course.testng Package;
Import org.testng.annotations *;.
public class BasicAnnotation {
// basic annotations, the method used to mark part of the test
@Test
public TestCase1 void () {
System.out.println ( "test this is a test case. 1");
}
@Test
public void testCase2 () {
System.out.println ( "test this is a test case 2");
}
@BeforeMethod
public void beforeMethod () {
System.out.println ( "BeforeMethod this test was run before the method");
}
@AfterMethod
public void afterMethod () {
System.out.println ( "AfterMethod which is run after the test methods");
}
@BeforeClass
public void BeforeClass () {
System.out.println ( "beforeClass which is in the process of run before class");
}
@AfterClass
public void AfterClass () {
System.out.println ( "AfterClass which is in the process of running after running class");
}
@ BeforeSuite
public void BeforeSuite () {
System.out.println ( "BeforeSuite test suite");
}
@AfterSuite
public void AfterSuite () {
System.out.println ( "AfterSuite test suite");
}
}
The output: