/** * */ package com.dtsz.groboTest; import junit.framework.TestCase; import net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner; import net.sourceforge.groboutils.junit.v1.TestMonitorRunnable; import net.sourceforge.groboutils.junit.v1.TestRunnable; import org.junit.Test; /** * @author xiaoli * */ public class MainTest1 extends TestCase{ @Override protected void setUp() throws Exception { // TODO Auto-generated method stub super.setUp(); System.out.println("setUp()数据准备"); } @Override protected void tearDown() throws Exception { // TODO Auto-generated method stub super.tearDown(); System.out.println("tearDown()结束"); } @Test public void test1() throws Throwable { int count = 2; long time = 0; TestRunnable[] tr = new TestRunnable[count]; TestMonitorRunnable [] trm = new TestMonitorRunnable[count]; for(int i = 0;i<count;i++) { TestRunnable1 t = new TestRunnable1(i,(i+1)*time); TestMonitorRunnable1 m = new TestMonitorRunnable1(i,t); tr[i] = t; trm[i] = m; } MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(tr,trm); //没有在该时间内完成的线程将会被杀掉 mttr.runTestRunnables(); } } |