到 Google 资讯主页   
EasyJF首页   资料   源码   软件    论坛   网站    
   使用帮助    
    该信息为本站MyRSS系统缓存内容,部分图片及附件有可能无法正常使用.easyjf.comwww.matrix.org.cn无关,不对该信息负责.通过http://www.matrix.org.cn//resource/article/2007-05-28/p-unit_24f643ae-0c78-11dc-b33a-df989147150e.html访问该信息的原始内容.
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   
你是否有喝咖啡等待JUnit结果的经历?
作者: 来源:www.matrix.org.cn  发布时间:2007-06-17 08:37:06.843

至少我有过,不仅仅是喝咖啡,甚至是吃中饭,睡午觉,等待JUnit运行结果,以前总是抱怨机器太慢,现在,似乎情况有些变化,看下面的一个例子,有2个测试案例类[1],每个类4个方法,每个方法休息5秒钟,那么做一个简单的算术题,需要多长时间?

2*4*5=40秒,完全正确,你可以去倒一杯水,然后回来看结果了!
我机器上JUnit的运行结果为:
Run as -> JUnit - 40268ms

会有其他不同结果吗?p-unit给你答案,下面这段代码是运行p-unit的main函数:

public static void main(String[] args) {
  SoloRunner runner = new SoloRunner();
  runner.setExecutorPool(new ExecutorPoolImpl(2));
  runner.run(LongTimeExecutionPUnitTestSuite.class);
}


答案是什么?
[solo] Started running samples.LongTimeExecutionPUnitTestSuite
TestSuite: samples.LongTimeExecutionPUnitTestSuite
samples.LongTimeExecutionTest1
samples.LongTimeExecutionTest2
test1() - [5021.0ms]
test1() - [5021.0ms]
test2() - [5003.0ms]
test2() - [5022.0ms]
testA() - [5020.0ms]
testA() - [5000.0ms]
testB() - [5001.0ms]
testB() - [5033.0ms]
total: 8, failures:0 (GREEN) - 20360.0ms


每个方法还是休息了5秒钟, 结果是20秒,不是40秒。

下载 p-unit-0.10 0.10 release: https://sourceforge.net/project/showfiles.php?group_id=195736&package_id=232587&release_id=509772

p-unit 主页: http://p-unit.sourceforge.net

[1] 测试案例类
LongTimeExecutionTest1.java/LongTimeExecution2.java:
public class LongTimeExecutionTest1(2) extends TestCase {
public void test1() throws Exception {
Thread.sleep(5000);
}

public void test2() throws Exception {
Thread.sleep(5000);
}

public void testA() throws Exception {
Thread.sleep(5000);
}

public void testB() throws Exception {
Thread.sleep(5000);
}

}


更多p-unit消息: http://blog.csdn.net/zhanghuangzhu

 
相关文章
 
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   


EasyJF.com 2006 隐私政策 使用EasyJF前必读