Junit和Testng的区别

上一篇 / 下一篇  2014-05-09 10:49:11 / 个人分类:java selenium webdriver

1、不同点
   Junit
    1)setUp tearDown
   Testng
    1)BeforeClass  AfterClass  BeforeMehtod  AfterMethod 支持各种签名方式private、protected、public ;
    2)测试方法可以分组@Test(groups={"fun1","fun2"});
    3)在大型测试套件中,重新运行失败测试用例的能力,是Testng特有的一个特性,一旦Testng出现失败就会创建一个testng-failed.xml之后只对运行失败的用例进             行就可以;
    4)Testng参数化
       1>第一种:testng.xml赋值
       2>第二种:Data Providers传参数 数据驱动 将外部方法传给测试方法并且循环起来
    5)并发测试
        1>Concurrent testing:
                   @Test(invocationCount = 5, threadPoolSize = 3) threadPoolSize用来指明线程池的大小,也就是并发的线程数目是多少
                2>Concurrent running of tests:
                  <suite name="Concurrent Suite" parallel="methods" thread-count="2" verbose="1" >
                <>……<>
             </suite>
         Parallel=”methods”的意思是指TestNG会将method作为并发的元子单位
     Thread-count=”2”是指,运行的时候,并发度为2,同时会有两个线程在运行
    6)依赖测试
      @Test的属性标签:dependsOnGroups以及dependsOnMethods
2、相同点

TAG:

 

评分:0

我来说两句

Open Toolbar