Eclipse+Junit test report

上一篇 / 下一篇  2010-01-14 17:46:51 / 个人分类:Selenium

转自Generating a JUnit test report with eclipse

clear instructions on how to use the built in functionality in eclipse to generate nice Junit reports in HTML using ant.

Now that I have found a solution to this problem I will post it in hopes that it might help others:

This approach is makes use of the eclipse2ant plug-in which is standard on Eclipse release 3.1M6 and higher (http://www.geocities.com/richard_hoefter/eclipse2ant/).
(注释:如果使用的是3.1版本以上的ECLIPSE则不用考虑
eclipse2ant插件问题)

1) First generate an Ant build file for your project.
In the Export page select "Ant Buildfiles" it is under General. Then select a project that contains your JUnit tests. The default JUnit output directory is appropriately named "junit".

(注释:在你的workspace中相应的PROJECT目录下创建一个名为'junit'的文件夹,以便存放输出结果)

2) Next resolve dependencies by making sure that the junit.jar is added to Ant's "Global Entries."
Window->Preferences->Ant->Runtime->Global Entries and Add External JARs... Navigate to your "eclipse" directory (where eclipse is installed). It is under "plugins" directory and presently the junit.jar is in a directory named "org.junit_3.8.1". If this is missing then you will see error messages since junit is an optional Ant task.


3) Run then right click on the Ant build file (by default build.xml) and Run As->Ant Build... This will display a list of targets. All of the launch configurations you have previously configured will have a corresponding target in your Ant build file. Select the desired target(s), and also select the "junitreport" target. Check the "Target execution order" text area to make sure the junitreport is run last.
(注释:在TARTGET list中选择时,要选择需要执行的TESTCASE和JUNITREPORT)

4) Access tojunit output directory of your project from your workspace path,click on index.html you will see the test result in browser.



Whenever you run a test case it will generate results and will be placed in the junit output directory. These results are formatted into an HTML report by the junitreport target and stored in the junit output directory. 

TAG:

 

评分:0

我来说两句

Open Toolbar