2、建立监控的线程,每个监控对应一个线程,也可以一个监控监控整个测试过程,需要传入监控的线程对象。

 

/**
*
*/
package com.dtsz.groboTest;
import net.sourceforge.groboutils.junit.v1.TestMonitorRunnable;
import net.sourceforge.groboutils.junit.v1.TestRunnable;
/**
* @author xiaoli
*
*/
public class TestMonitorRunnable1 extends TestMonitorRunnable {
private int i;
private TestRunnable t;
public TestMonitorRunnable1(int i,TestRunnable t) {
super();
this.i = i;
this.t = t;
}
/* (non-Javadoc)
* @see net.sourceforge.groboutils.junit.v1.TestMonitorRunnable#runMonitor()
*/
@Override
public void runMonitor() throws Throwable {
System.out.println(i+"线程监控正在跑…………状态:"+t.isDone());
}
}

 

   3、建立主测试类进行并发单元测试,这里只有简单数据打印,具体情况传入数据进行测试,比如Web项目中需要在setUp()中部署好相关的环境等: