是可以动态控制执行次数的,不过相对会复杂一些。
首先要弄清楚是怎么个调整次数,是整个测试集的次数,还是单个用例的次数,
如果是整个测试集应该比较简单,
如果是单个测试用例的话,在 testNG 中,可以在@test注解中加一个 invocationCount 参数,可以控制次数
到于服务器 ip 这个可以做一个全局参数来读取吧?当然也可以作为用例的参数传给用例,这里的差别就是一种是在用例中主动读取其他信息,另一种是被动接收信息
Go-Go
也可以用 sendevent
哪个平台,自己开发的平台?其他平台?
嗯,是的,自学的
Must have a good English skill, both in speaking and writing.
for (int i=0; i<APITestUtils.getBlockingQueue().size(); i++) {
TestNG testNG = new TestNG();
testNG.setTestClasses(new Class[]{APITestExecutor.class});
testNG.run();
}
可以啊
加我微信吧:15105163710
可能安装的不对呗,可以在命令行中执行 yasm 命令检查一下
如果安装对了,命令行执行,还是找不到,说明需要加到环境变量中去
额,好的吧,感谢大佬
在使用 javassist 时,调用 cc.toClass() 方法就拿到类实例了,你再好好看看吧,去敲了试试
Class executor = cc.toClass();
TestNG testNG = new TestNG(false);
testNG.setSuiteThreadPoolSize(1);
testNG.setThreadCount(1);
testNG.setTestClasses(new Class[]{TestExecutor.class});
testNG.run();
可以的,使用 cglib 动态生成的,可以通过 Class.forName 进行加载,也可以借助 javassist 进行动态生成类,参看我的另一篇文章:https://testerhome.com/topics/18811
你是说这个吗?
testNG.setThreadCount(Runtime.getRuntime().availableProcessors() + 1);
没达到效果噢
public class Demo1 {
@DataProvider
public Object[][] getData() {
Object[][] objects = new Object[3][3];
for (int i=0; i<objects.length; i++) {
for (int j=0; j<objects[i].length; j++) {
objects[i][j] = i + "-" + j;
}
}
return objects;
}
@Test(dataProvider = "getData", threadPoolSize = 4)
public void runData(Object... objects) {
System.out.println(System.currentTimeMillis());
System.out.println(Thread.currentThread().getName());
for (int i=0; i<objects.length; i++) {
System.out.println(objects[i]);
ThreadUtils.sleep(100);
}
System.out.println();
}
public static void main(String[] args) {
TestNG testNG = new TestNG(false);
testNG.setThreadCount(Runtime.getRuntime().availableProcessors() + 1);
testNG.setPreserveOrder(true);
testNG.setTestClasses(new Class[]{Demo1.class});
testNG.run();
}
}
嗯,需要再结合业务深入思考一下,
另外从接口请求类型角度考虑,
比如,有 AB 两个接口,当这两个都是 GET 接口时,视为同一种场景,
总的来说,需要把总的量给控制在一定范围内来跑
治本方法:
治标方法:
我试了一下,未达到并行执行的效果,它是串行的,我的测试代码如下:
@DataProvider
public Object[][] getData() {
Object[][] objects = new Object[3][3];
for (int i=0; i<objects.length; i++) {
for (int j=0; j<objects[i].length; j++) {
objects[i][j] = i + "-" + j;
}
}
return objects;
}
@Test(dataProvider = "getData", threadPoolSize = 4)
public void runData(Object... objects) {
System.out.println(System.currentTimeMillis());
System.out.println(Thread.currentThread().getName());
for (int i=0; i<objects.length; i++) {
System.out.println(objects[i]);
ThreadUtils.sleep(100);
}
System.out.println();
}
嗯,之前有想过,忘记为啥没去试这条路了
嗯,你说的对,在本例中,并没有使用到动态代理的特性,去增加前置、后置、或环绕什么的方法,准确来说是动态生成了一个子类。
多线程来实现是指下面这个参数吗?从注解来看,是跑这个方法多次
public @interface Test {
/**
* The size of the thread pool for this method. The method will be invoked
* from multiple threads as specified by invocationCount.
* Note: this attribute is ignored if invocationCount is not specified
*/
public int threadPoolSize() default 0;
}
噢?说说看,怎么用的?我学习下
这位大神,你在讲什么?
跟青云有关系,现在都用的云服务,然而云服务商相关的配置功能并没有到位
espresso 是支持 webview 的啊