[英]How do I get one junit report from TestNG for all my test cases?
I have a TestNG xml file formatted like this: 我有一个TestNG xml文件,其格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="MySuite" parallel="tests" thread-count="5">
<parameter name="browser" value="firefox" />
<parameter name="remoteOrLocal" value="local" />
<parameter name="environment" value="####" />
<parameter name="remoteAddress" value="0.0.0.0" />
<test name="1" >
<classes>
<class name="tests.Test1"/>
</classes>
</test>
<test name="2">
<classes>
<class name="tests.Test2"/>
</classes>
</test>
<test name="3">
<classes>
<class name="tests.Test3"/>
</classes>
</test>
</suite
But I use a test case management tool that requires junit output which shouldn't be a problem since TestNG generates junit output automatically. 但是我使用了一个需要用junit输出的测试用例管理工具,这不是问题,因为TestNG自动生成了junit输出。
The problem is this: In the directory under test-output called junitreports, there is one junit report for each class in the following format: 问题是这样的:在test-output下的名为junitreports的目录中,每个类都有一个junit报告,格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by org.testng.reporters.JUnitReportReporter -->
<testsuite hostname="fadavis-HP-EliteBook-8470p" name="tests.Test1" tests="3" failures="1" timestamp="15 May 2015 19:25:12 GMT" time="0.023" errors="1">
<testcase name="method1" time="0.012" classname="tests.Test1"/>
<testcase name="method3" time="0.004" classname="tests.Test1"/>
<testcase name="method2" time="0.007" classname="tests.Test1">
<error type="java.lang.AssertionError" message="null">
<![CDATA[java.lang.AssertionError: null
at org.testng.Assert.fail(Assert.java:94)
at org.testng.Assert.fail(Assert.java:101)
at tests.Test1.method2(Test1.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.access$000(SuiteRunner.java:37)
at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:368)
at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
]]>
</error>
</testcase> <!-- method2 -->
</testsuite> <!-- tests.Test1 -->
where the suite name is the same as the classname. 套件名称与类名称相同。 How can I get just one Junit report file with the results from a suite of TestNG tests? 我如何只获得一个Junit报告文件以及一组TestNG测试的结果?
There should be directory called MySuite
on same level as junitreports
(basically name from your <suite name="MySuite" parallel="tests" thread-count="5">
) and inside is one XML for all tests. 应该有所谓的目录MySuite
在同一水平junitreports
(从基本的名字<suite name="MySuite" parallel="tests" thread-count="5">
和里面的所有测试一个XML。
This is generated by org.testng.reporters.JUnitXMLReporter
if it's not there, try to add this reporter to your listeners. 如果不存在此文件,则由org.testng.reporters.JUnitXMLReporter
生成,请尝试将此报告程序添加到您的侦听器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.