准备:TestNG、Selenium、Maven

1、在 pom.xml 文件中增加配置项。 

##################

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.14.3</version>
    <scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.4.0</version>
</dependency>

#################

2、@Test(invocationCount = N)

其中 N 是 TestNG 应该运行这个测试方法的次数。

实例一:repeatThis()方法将运行10次

3、@Test ( invocationCount = ?, threadPoolSize = ? )

threadPoolSize : 表示线程池的内线程的个数;

invocationCount :表示执行的次数;

timeOut :超时时间-毫秒;

实例一:

备注:每次运行结果不一样。

4、负载测试实例

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐