TestRunnable runner = new TestRunnable() {
@Override
public void runTest() throws Throwable {
//你的测试内容
}
};
int runnerCount = 30;
//Rnner数组,想当于并发多少个。
TestRunnable[] trs = new TestRunnable[runnerCount];
for (int i = 0; i < runnerCount; i++) {
trs[i] = runner;
}
// 用于执行多线程测试用例的Runner,将前面定义的单个Runner组成的数组传入
MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs);
try {
// 开发并发执行数组里定义的内容
mttr.runTestRunnables();
} catch (Throwable e) {
e.printStackTrace();
}
<dependency>
<groupId>net.sourceforge.groboutils</groupId>
<artifactId>groboutils-core</artifactId>
<version>5</version>
</dependency>
相关jar包 需要导入junit的jar包 还有groboutils-core-5.jar
或maven 打包jar
mvn install:install-file -Dfile=xxx.jar -DgroupId=xxx.xx.x -DartifactId=xxx -Dversion=1.0 -Dpackaging=jar