创建Java报表项目 - 想使用JUnit和Ant但不知道如何 [英] Creating a Java reporting project -- would like to use JUnit and Ant but not sure how

查看:231
本文介绍了创建Java报表项目 - 想使用JUnit和Ant但不知道如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很感兴趣,产生了一定的群体使用JUnit在我公司(非软件)工程师报告。与典型的JUnit测试你在哪里保障对象,方法等都没有错误,我想使用JUnit确认是否会导致较大的日志文件在范围之内,并给它的报告。

I'm interested in generating reports for a certain group of (non-software) engineers in my company using JUnit. Unlike typical JUnit testing where you are ensuring objects, methods, etc are bug free, I want to use JUnit to confirm if results in large log files are within range and give reports on it.

我的背景:与Java经验。我熟悉JUnit 4,我花了最后一小时或2翻翻ANT文档和我认为我有它是如何工作的一个强烈的想法(我只是不知道所有的XML命令),我使用Eclipse宗教。具体的Eclipse六月(最新的)。

My background: Experienced with Java. I am familiar with JUnit 4, I have spent the last hour or 2 looking through ANT documentation and I think I have a strong idea how it works (I just don't know all the XML commands), and I use Eclipse religiously. Specifically Eclipse June (latest).

我的目标是创建一个断言,如果在日志中值是正确的范围内测试用例的转换。测试类几乎可以在每一个日志文件反复执行。每次运行之后,结果将被添加到一个HTML文件

My goal is to create a slew of testcases that assert if the values in the logs are within the right range. The test class can then be run over and over on every single log file. After each run, the results will be added to an HTML file.

我知道了JUnit报告功能Ant中,但我有很多的麻烦把拼图的各个部分一起正常。我知道我可以破解我的方式,通过这个项目很容易,但我想这样做的正确方法。

I am aware of the JUnit Report features in Ant but I am having a lot of trouble putting all the pieces of the puzzle together properly. I know I can hack my way through this project quite easily, but I want to do this the right way.

可以任意点我朝着正确的方向如何:

Can any point me in the right direction in how to:


  • 请正确的build.xml文件

  • 设置了JUnit类/套/亚军,使其运行一遍又一遍的日志给定的名单

  • 设置了ANT因此它输出HTML / XML以及如何将其指向正确的样式表,以便它可以在IE / Firefox中打开

  • 如何使输出文件

  • 覆盖功能,这样的报告是自定义的。

  • 什么来覆盖后处理。 (这样我就可以输出HTML转换成PDF等)

  • 如何创建一个独立的可执行文件,它会自动做这一切 - 也许结合了摆动小,如果用户不手动提供输入。

  • 如何正确遍历多次试验(目前我只是作出主要功能及这样做的:

code:

public static void main(String[] args) {
    JUnitCore junit = new JUnitCore();
    RunListener listener = new RunListener();
    junit.addListener(listener);
    Result result = junit.run(GearAndBrakeFaultLogReports.class);
    for (Failure f : result.getFailures()) {
        System.out.println(f.toString());
        System.out.println(f.getDescription());
        System.out.println(f.getTestHeader());
        System.out.println(f.getException());
        System.out.println(f.getMessage());
    }
    System.out.println("Done.");
}


  • 我有一种感觉,就是这样做的哈克的方式,如果我知道如何插入蚂蚁得当,它将运行我的测试中,生成XML / HTML,我会输出所需。

  • 我想象的那样这个项目的发展,我将有更多的问题,但我想获得比最初驼峰将是我非常好!我知道有很多问题,所以任何帮助,我会很乐意凹凸点:)我的希望是,有人熟悉这些工具可以回答所有这些带有指向我的网站,功能或示例项目的问题,做类似的事情。

    I imagine I will have more questions as this project develops, but I think getting over the initial hump will be very good for me! I know there are a lot of questions, so any help and I'll gladly point bump :) My hope is, someone familiar with these tools can answer all these with a matter of pointing me to web sites, functions, or an example project that does a similar thing.

    推荐答案

    有关创建从JUnit测试结果的PDF:
    http://junitpdfreport.sourceforge.net/managedcontent/

    For creating a PDF from JUnit test results: http://junitpdfreport.sourceforge.net/managedcontent/

    作为一个单元测试frameword,JUnit的报告是非常具体的软件工程。虽然,你的可能的能够自定义它为一个非单元测试的情况下,它会占用大量定制的。不同于其他测试框架(如TestNG的)的JUnit并没有提供让自己的报表生成器的能力。 TestNG的,然而,可以用于运行JUnit测试,甚至在除了其自己的报告产生一个JUnit报告。 TestNG的可以运行JUnit测试,然后通过提供org.testng.IReporter界面的自定义实现创建自定义报告。

    As a unit testing frameword, JUnit reports are very specific to software engineering. Although, you might be able to customize it for a non-unit testing scenario, it will take a lot of customizing. Unlike other testing frameworks (such as TestNG) JUnit doesn't provide the ability to make your own report generator. TestNG, however, can be used to run JUnit tests and even produces a JUnit report in addition to its own reports. TestNG can run your JUnit tests and then create custom reports by providing a custom implementation of the org.testng.IReporter interface.

    http://testng.org/doc/documentation-main.html

    已经书面报告中的Java多年了,我会强烈建议尝试了报告工具,如的JasperReports和iReport的工具。 Jasper报表可以处理自定义数据源,如您的日志文件,并产生多种格式,包括XML,HTML和PDF报告。

    Having written reports in Java for many years now, I would strongly recommend trying out a reporting tool such as JasperReports and the iReport tool. Jasper Reports can process custom data sources such as your log files and produce reports in many formats, including XML, HTML, and PDF.

    http://community.jaspersoft.com/project/ireport-designer

    这篇关于创建Java报表项目 - 想使用JUnit和Ant但不知道如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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