JUnit的:如何避免误报使用forkMode =&QUOT时,一旦"? [英] junit: how to avoid false positives when using forkMode="once"?

查看:416
本文介绍了JUnit的:如何避免误报使用forkMode =&QUOT时,一旦"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想加快JUnit测试,我想关于使用 forkMode =曾经

由于这样的事实的junit <一href=\"http://stackoverflow.com/questions/6254965/junit-impact-of-forkmode-once-on-test-correctness\">seems使用共享的类加载器以假阴性旁边一个进程内的所有测试(这是很好的事情,因为它暴露了静态耦合)有可能由同一个原因是还误报。

我有两个问题关于本:


  1. 时,它在某种程度上可以改变在JUnit类加载器行为的执行每个测试用例一个新的类加载器?我认为这将是理想的,能够在两个mdoes以避免假阳性和阴性运行JUnit。


  2. 时,很容易可以的随机测试订单,以减少误报的概率(使用ANT)



解决方案

据我知道你想要什么,不支持,但在任何情况下,我想你应该重新考虑你的方法:你应该让你的code更容易测试,所以它不会依赖于一个新的JVM /类加载器。

但是,如果你不能/不会 - 你最好的行动当然是叉

I'd like to speed up junit tests and I think about using forkMode="once".

Due to the fact that junit seems to use a shared classloader for all tests within one process beside false negatives (which is good thing because it exposes static coupling) there might be also false positives by the same reason.

I've got two questions regarding this:

  1. Is it somehow possible to alter the classloader behavior in junit to enforce a new classloader for each test case? I think it would be ideal to be able to run junit in both mdoes to avoid both false positives and negatives.

  2. Is it easily possible to randomize test order to decrease the probability of false positives (using ant)

解决方案

As far as I know what you want is not supported, but in any case, I think you should reconsider your approach: you should make your code more testable so it will not depend on a new JVM/Classloader.

But if you can't/won't - your best course of action is to fork.

这篇关于JUnit的:如何避免误报使用forkMode =&QUOT时,一旦&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆