English 中文(简体)
日尼特测试报告与JavaDoc的浓缩
原标题:JUnit test report enrichment with JavaDoc

对客户而言,我们需要为融合测试编写详细的测试报告,不仅显示,一切都是绿色的,而且测试是什么样的。 我的同事和我是 la笑,我们不希望打上传播画或文字文件。

为此,我认为,将比较复杂的一体化测试与JavaDoc关于每一种“试验附加说明”方法和每一试验类别的评论相记录。 试卷可很好地看出,哪项要求、吉拉票或任何测试都与测试有关,以及测试实际上试图做些什么。 我们也要向我们的客户提供这一信息。

现在的主要问题是:我们如何能够将 Java的每个方法和每个测试类别纳入日本国别报告? 我们使用Junnit 4.9和Maven。

I know, that there is a description for each assertXXX(), but we really would need a nice HTML list as result or a PDF document which lists all classes and there documentation and below that all @Test methods and their description, the testing time, the result and if failed, the reason why.

或者还有另一种替代方法,可以产生弹性测试文字? (我们应就此启动开放式项目!) iii

Update: I asked another question on how to add a RunListener to Eclipse to have it also report in Eclipse when started there. The proposed solution with a custom TestRunner is another possibility to have the test results report. Have a look: How can I use a JUnit RunListener in Eclipse?

最佳回答

One way to achieve this would be to use a custom RunListener, with the caveat that it would be easier to use an annotation rather than javadoc. You would need to have a custom annotation such as:

@TestDoc(text="tests for XXX-342, fixes customer issue blahblah")
@Test
public void testForReallyBigThings() {
    // stuff
}

<代码>RunListener聆听了测试活动,例如测试开始、测试结束、测试失败、测试成功等。

public class RunListener {
    public void testRunStarted(Description description) throws Exception {}
    public void testRunFinished(Result result) throws Exception {}
    public void testStarted(Description description) throws Exception {}
    public void testFinished(Description description) throws Exception {}
    public void testFailure(Failure failure) throws Exception {}
    public void testAssumptionFailure(Failure failure) {}
    public void testIgnored(Description description) throws Exception {}
}

Description载有适用于测试方法的说明清单,因此,采用上述例子,您可采用以下方法获得“通知”测试Doc:

description.getAnnotation(TestDoc.class);

案文照常印发。

然后,你可以使用<代码>RunListener,生成你想要的档案,具体文本是这一检验的结果还是失败,还是被忽略的时间等。 这将是你的习惯报告。

之后,你可以肯定地说出一位习俗听众,使用:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.10</version>
  <configuration>
    <properties>
      <property>
        <name>listener</name>
        <value>com.mycompany.MyResultListener,com.mycompany.MyResultListener2</value>
      </property>
  </configuration>
</plugin>

This is from Maven Surefire Plugin, Using JUnit, Using custom listeners and reporters

这种办法的缺点是,就运输回报而言,你没有灵活性,但就格式问题而言,它确实有好处,即文件在一个具体地点,即通知测试。

问题回答

你们是否看过Maven Sure-fire的报告?

You can generate a HTML report from your JUnit Tests.

http://maven.apache.org/plugins/maven-surefire-report-plugin/

我不敢确定,它是如何定制的。 但这是一个良好的起点。

I also know that TestNG ( alternative to JUnit ) has some report generating capabilities. http://testng.org/doc/documentation-main.html#logging-junitreports

I would also recommend log4j http://logging.apache.org/log4j/1.2/manual.html

页: 1 测试报告的良好框架。

I have created a program using testNG and iText which outputs the test results in a nice pdf report. You can put a description of your test in the @Test tag, and that can be included in the .pdf report also. It provides the run times of the tests, and for the entire suite. It is currently being used to test webapps with selenium, but that part could be ignored. It also allows you to run multiple test suites in one run, and if tests fail, it allows you to re-run only those tests without having to re-run the entire suite, and those results will be appended to the original results PDF. See below the image for a link to the source if you are interested. I wouldn t mind this becoming an opensource project as I have a good start on it, though I m not sure how to go about doing that. Here s a screenshot enter image description here

因此,我说明了如何建立一个关于来源的项目。 这里链接sourceforge链接

如上所述,这无疑是前进的道路。 这使得生活真正容易。 你们能够创造一个非常容易利用m2eclipse plugin的马文项目。 一旦完成这项工作。 仅管理这些指挥:

cd <project_dir_where_you_have_pom_file>
mvn site:site

这一指挥将为你们创造风格。 同一目录:

mvn surefire-report:report

这将处理测试案件,并将产出转换到html。 您可在目标/现场/火灾报告中找到产出。

以下是 s。 由于你能够看到所有的测试案例(在Junnit撰写的)都在html中显示。 还有一些像没有检测病例一样的甲状腺素,还有多少成功、花费的时间等。

由于我无法上载图像,我必须显示产出。

你们还可以向前迈出一步,并且能够使金刚石的准确版本像使用一样。

mvn org.apache.maven.plugins:maven-site-plugin:3.0:site org.apache.maven.plugins:maven-surefire-report-plugin:2.10:report




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签