Show excution order for Before and After annotations
This commit is contained in:
commit
17bfe63ea8
|
|
@ -0,0 +1,10 @@
|
|||
# Eclipse IDE settings files:
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings/
|
||||
|
||||
# Build generated folders:
|
||||
/bin/
|
||||
|
||||
# TestNG generated folders:
|
||||
test-output/
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# TestNG
|
||||
|
||||
Examples showing some TestNG features.
|
||||
|
||||
## Run on Eclipse
|
||||
|
||||
1. **Package Explorer**
|
||||
2. Contextual menu on `TestRunner.xml` > **Run As** > **TestNG Suite**
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
|
||||
|
||||
<suite name="TestNGExampleSuite" verbose="1">
|
||||
<test name="TestNGExampleTests">
|
||||
<classes>
|
||||
<class name="tests.TestA" />
|
||||
<class name="tests.TestB" />
|
||||
</classes>
|
||||
</test>
|
||||
<test name="TestNGMoreExampleTests">
|
||||
<classes>
|
||||
<class name="tests.TestA" />
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package tests;
|
||||
|
||||
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 abstract class BaseTest
|
||||
{
|
||||
|
||||
@BeforeSuite
|
||||
public void beforeSuite()
|
||||
{
|
||||
System.out.println("Before Suite");
|
||||
}
|
||||
|
||||
@BeforeTest
|
||||
public void beforeTest()
|
||||
{
|
||||
System.out.println("' Before Test");
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public void beforeClass()
|
||||
{
|
||||
System.out.println("' ' Before Class");
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void beforeMethod()
|
||||
{
|
||||
System.out.println("' ' ' Before Method");
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void afterMethod()
|
||||
{
|
||||
System.out.println("' ' ' After Method");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public void afterClass()
|
||||
{
|
||||
System.out.println("' ' After Class");
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
public void afterTest()
|
||||
{
|
||||
System.out.println("' After Test");
|
||||
}
|
||||
|
||||
@AfterSuite
|
||||
public void afterSuite()
|
||||
{
|
||||
System.out.println("After Suite");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package tests;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class TestA extends BaseTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testMethod01()
|
||||
{
|
||||
System.out.println("' ' ' ' TestA.testMethod01()");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethod02()
|
||||
{
|
||||
System.out.println("' ' ' ' TestA.testMethod02()");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethod03()
|
||||
{
|
||||
System.out.println("' ' ' ' TestA.testMethod03()");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package tests;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class TestB extends BaseTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testMethod01()
|
||||
{
|
||||
System.out.println("' ' ' ' TestB.testMethod01()");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethod02()
|
||||
{
|
||||
System.out.println("' ' ' ' TestB.testMethod02()");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethod03()
|
||||
{
|
||||
System.out.println("' ' ' ' TestB.testMethod03()");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue