【问题标题】:Is there a chance to add descriptions to JUnit tests?是否有机会向 JUnit 测试添加描述?
【发布时间】:2012-11-12 10:18:23
【问题描述】:

JUnit 是否可以为每个测试方法添加描述文本,以便描述文本稍后出现在surefire/failsave xml 报告中!?

背景:我在一个受监管的环境中工作,必须编写大量文档、测试规范和测试报告。 JUnit 测试报告是文档的一部分,我们希望将测试描述直接放在 JUnit 测试中,以便将它们放在一个地方。由于测试会不断发展和出现,而有些测试会被删除,因此很难将测试描述放在与测试不同的工具或位置。

我喜欢的是这样的:

public class MyTest {

   @Test
   @TestDescription("The test will do this and that. Preconditions are: 
                      1. bla blubb
                      2. bla fasel"
  public void testDoMyTestShouldCheckSomething {
    [...]
  }
}

【问题讨论】:

    标签: junit junit4


    【解决方案1】:

    我会考虑与我对JUnit test report enrichment with JavaDoc 的回答类似的方案。

    基本上,使用 RunListener 生成基于测试结果的报告,使用测试上的注释来提供描述。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-16
      相关资源
      最近更新 更多