1 package test.mannotation; 2 3 import org.testng.annotations.AfterClass; 4 import org.testng.annotations.AfterGroups; 5 import org.testng.annotations.AfterMethod; 6 import org.testng.annotations.AfterSuite; 7 import org.testng.annotations.AfterTest; 8 import org.testng.annotations.BeforeClass; 9 import org.testng.annotations.BeforeGroups; 10 import org.testng.annotations.BeforeMethod; 11 import org.testng.annotations.BeforeSuite; 12 import org.testng.annotations.BeforeTest; 13 import org.testng.annotations.Configuration; 14 import org.testng.annotations.DataProvider; 15 import org.testng.annotations.ExpectedExceptions; 16 import org.testng.annotations.Factory; 17 import org.testng.annotations.Parameters; 18 import org.testng.annotations.Test; 19 20 @Test(enabled = true, groups = {"group1", "group2"}, 21 alwaysRun = true, parameters = {"param1", "param2"}, 22 dependsOnGroups = {"dg1", "dg2"}, dependsOnMethods = {"dm1", "dm2"}, 23 timeOut = 42, invocationCount = 43, successPercentage = 44, 24 threadPoolSize = 3, 25 dataProvider = "dp", description = "Class level description") 26 public class MTest1 { 27 28 @Test(enabled = true, groups = {"group5", "group6"}, 29 alwaysRun = true, parameters = {"param5", "param6"}, 30 dependsOnGroups = {"dg5", "dg6"}, dependsOnMethods = {"dm5", "dm6"}, 31 timeOut = 242, invocationCount = 243, successPercentage = 62, 32 dataProvider = "dp3", description = "Constructor description", 33 expectedExceptions = NumberFormatException.class) MTest1()34 public MTest1() {} 35 36 @Test(enabled = true, groups = {"group3", "group4"}, 37 alwaysRun = true, parameters = {"param3", "param4"}, 38 dependsOnGroups = {"dg3", "dg4"}, dependsOnMethods = {"dm3", "dm4"}, 39 timeOut = 142, invocationCount = 143, successPercentage = 61, 40 dataProvider = "dp2", description = "Method description", 41 expectedExceptions = NullPointerException.class) f()42 public void f() {} 43 44 @Configuration(beforeSuite = true, beforeTestMethod = true, 45 beforeTest = true, beforeTestClass = true, 46 beforeGroups = { "b1", "b2"}) before()47 public void before() {} 48 49 @Configuration(afterSuite = true, afterTestMethod = true, 50 afterTest = true, afterTestClass = true, 51 afterGroups = {"a1", "a2"}) after()52 public void after() {} 53 54 @Configuration(parameters = {"oparam1", "oparam2"}, 55 enabled = false, groups = {"ogroup1", "ogroup2"}, 56 dependsOnGroups = {"odg1","odg2"}, 57 dependsOnMethods = {"odm1", "odm2"}, alwaysRun = true, 58 inheritGroups = false, 59 description = "beforeSuite description") 60 @DataProvider(name = "dp4") 61 @ExpectedExceptions({MTest1.class, MTest2.class }) otherConfigurations()62 public void otherConfigurations() {} 63 64 @Factory(parameters = {"pf1", "pf2"}) factory()65 public void factory() {} 66 67 @Parameters({"pp1", "pp2", "pp3"}) parameters()68 public void parameters() {} 69 70 @BeforeSuite 71 @BeforeTest 72 @BeforeGroups 73 @BeforeClass 74 @BeforeMethod newBefore()75 public void newBefore() {} 76 77 @AfterSuite 78 @AfterTest 79 @AfterGroups 80 @AfterClass 81 @AfterMethod newAfter()82 public void newAfter() {} 83 84 } 85