稳定性测试

稳定性测试

invocationCount 调用的执行次数
invocationTimeOut 执行多次后总耗时
@Test(invocationCount = 5, invocationTimeOut = 5100) 执行5次,总耗时为5.1秒

在com.course.testng包里新建TimeOutTest类,代码如下:

package com.course.testng;

import org.testng.annotations.Test;

public class TimeOutTest {

	@Test(invocationCount = 5, invocationTimeOut = 5100)
	public void  loginTest() throws InterruptedException{
		
		Thread.sleep(2000);
		System.out.println("login test");
	}
}

测试结果,总耗时5秒,用例执行成功
这两个参数有什么作用呢?在接口测试中,或者性能测试。我们需要测试某一个功能的稳定性。例如,一个支付接口,调用一次,能够在1秒完成。那么如果调用100次,1万次,甚至更多次数。我想,大家都知道,随着服务器压力增加,不可能每次接口执行都是1秒。例如,我测试支付接口10次,总响应时间不能超过13秒。如果测试超过13秒,说明这个接口性能角度,或者压力测试角度,稳定性角度是有缺陷的,需要开发去想办法优化。

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42884654/article/details/82911919