Java编程之testng

一.概念

testng是单元测试框架,提供了丰富的注解

@Test注释写在方法之前

需要执行的用例前要加上@Test注释或者前置后置注释

二.属性标注

1.永远执行(默认值为false)

@Test(alwaysRun=true)

2.依赖方法:依赖的方法会先执行

@Test(dependsOnMethods = {"test2"})

3.执行方法优先级

@Test(priority = 3)

4.循环次数和并发线程

 @Test(invocationCount = 10,threadPoolSize = 3)

5.使方法失效(默认值true)

@Test(enabled =false )

三.testng.xml

点击resource--Creat TestNG XML(需要先在Plugins里下载create testng xml插件),在classes中添加要执行的class

 

 name为文件的相对路径,可添加多个类,执行testng.xml即可执行所有添加的类

四.前置后置注解

BeforeSuite/AfterSuite

BeforeTest/AfterTest

BeforeClass/AfterClass

BeforeMethod/AfterMethod

posted @ 2025-04-23 22:13  思佳丽  阅读(9)  评论(0)    收藏  举报