如何指定JUnit测试依赖项? [英] How can I specify JUnit test dependencies?

查看:308
本文介绍了如何指定JUnit测试依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的工具包具有15000多个 JUnit 测试,并且已知许多测试会在其他测试失败的情况下失败.例如,如果方法X.foo()使用Y.bar()中的功能并且YTest.testBar()失败,则XTest.testFoo()也将失败.显然,由于特定于X.foo()的问题,XTest.testFoo()也可能会失败.

Our toolkit has over 15000 JUnit tests, and many tests are known to fail if some other test fails. For example, if the method X.foo() uses functionality from Y.bar() and YTest.testBar() fails, then XTest.testFoo() will fail too. Obviously, XTest.testFoo() can also fail because of problems specific to X.foo().

虽然这很好,但我仍然希望同时运行两个测试,但是如果可以使用指向YTest.testBar()的XTest.testFoo()注释测试依赖项,那就太好了.这样,人们可以立即看到X.foo()使用的功能也失败了,而没有失败.

While this is fine and I still want both tests run, it would be nice if one could annotate a test dependency with XTest.testFoo() pointing to YTest.testBar(). This way, one could immediately see what functionality used by X.foo() is also failing, and what not.

在JUnit或其他地方是否有这样的注释?像这样:

Is there such annotation available in JUnit or elsewhere? Something like:

public XTest {

  @Test
  @DependsOn(method=org.example.tests.YTest#testBar)
  public void testFoo() {
     // Assert.something();
  }

}

推荐答案

JExample TestNG 有类似的东西.

我不知道它有什么用,但是如果您尝试使用它,请回来告诉我们它是否有用.

I don't know how useful it is, but if you try it, please come back to tell us whether it was useful.

这篇关于如何指定JUnit测试依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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