testng简介
1.@Test注解
2.@BeforeClass(alwaysRun = true)
((beforeSuite, beforeTest, beforeTestClass , beforeTestMethod)
3.@AfterClass(alwaysRun = true)/@AfterMethod
对于每个bufore方法(beforeSuite, beforeTest, beforeTestClass 和 beforeTestMethod, 但是不包括 beforeGroups):
如果设置为true,被配置的方法将总是运行而不管它属于哪个组。
对于after方法(afterSuite, afterClass, ...): 如果设置为true,被配置的方法甚至在一个或多个先调用的方法失败或被忽略时也将运行。
4.priority
@Test(priority = 1)
不填写,默认是0
执行顺序从小到大
可以进行简单的参数传递
5.invocationCount
当前方法被调用的次数
@Test(invocationCount= 10)
6.threadPoolSize
当前方法的线程池大小
@Test(threadPoolSize = 10)
7.@DataProvider
@DataProvider(name = "data") public Object[][] testData2() { return new Object[][]{ {"value1","value2","value2"}, {"value1","value2","value2"} }; }
@Test(dataProvider = "data") public void data02Test(String v1,String v2,String v3){ System.out.println(a); System.out.println(v1+v2+v3); }
8.enabled = false, dependsOnGroups, dependsOnMethods,groups
@Test(dependsOnMethods = "dependsOnMethodsTest01")
9.expectedExceptions ,expectedExceptionsMessageRegExp
@Test(expectedExceptions = ArithmeticException.class,expectedExceptionsMessageRegExp = "111")