即使更改脚本以生成失败结果,Jenkins也会显示PASSNG的结果

时间:2017-09-12 22:12:23

标签: jenkins testng

我已将testng-results.xml上传到git分支中,并使用git存储库作为Jenkins作业的工作区。

由于我在Jenkins上运行的测试是回归测试,因此我认为TestNG报告在任何情况下都会出现回归缺陷。我注意到Jenkins上显示的TestNG报告只是testng-results.xml文件的可读版本,即它是我工作区中testng-results.xml文件的精确副本。

我已将测试脚本ChromeTest.f()更改为故意失败,而Jenkins仍将测试结果标记为PASS,如下图所示:

Jenkins screenshot

请在下面找到testng-results.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<testng-results skipped="0" failed="0" ignored="0" total="9" passed="9">
<reporter-output>
</reporter-output>
<suite name="Default suite" duration-ms="159837" started-at="2017-09-12T16:48:30Z" finished-at="2017-09-12T16:51:10Z">
<groups>
</groups>
<test name="Default test" duration-ms="159837" started-at="2017-09-12T16:48:30Z" finished-at="2017-09-12T16:51:10Z">
<class name="IETests">
<test-method status="PASS" signature="beforeTest()[pri:1, instance:IETests@7921b0a2]" name="beforeTest" duration-ms="18341" 
started-at="2017-09-12T09:48:30Z" finished-at="2017-09-12T09:48:49Z">
<reporter-output>
</reporter-output>
</test-method> <!-- beforeTest -->
<test-method status="PASS" signature="f()[pri:2, 
instance:IETests@7921b0a2]" name="f" duration-ms="99893" started-
at="2017-09-12T09:48:49Z" finished-at="2017-09-12T09:50:29Z">
<reporter-output>
</reporter-output>
</test-method> <!-- f -->
<test-method status="PASS" signature="afterTest()[pri:3, 
instance:IETests@7921b0a2]" name="afterTest" duration-ms="115" 
started-at="2017-09-12T09:50:29Z" finished-at="2017-09-12T09:50:29Z">
<reporter-output>
</reporter-output>
</test-method> <!-- afterTest -->
</class> <!-- IETests -->
<class name="ChromeTest">
<test-method status="PASS" signature="beforeTest()[pri:4, 
instance:ChromeTest@1efbd816]" name="beforeTest" duration-ms="12606" 
started-at="2017-09-12T09:50:29Z" finished-at="2017-09-12T09:50:41Z">
<reporter-output>
</reporter-output>
</test-method> <!-- beforeTest -->
<test-method status="PASS" signature="f()[pri:5, 
instance:ChromeTest@1efbd816]" name="f" duration-ms="1087" started-
at="2017-09-12T09:50:41Z" finished-at="2017-09-12T09:50:42Z">
<reporter-output>
</reporter-output>
</test-method> <!-- f -->
<test-method status="PASS" signature="afterTest()[pri:6, 
instance:ChromeTest@1efbd816]" name="afterTest" duration-ms="243" 
started-at="2017-09-12T09:50:43Z" finished-at="2017-09-12T09:50:43Z">
<reporter-output>
</reporter-output>
</test-method> <!-- afterTest -->
</class> <!-- ChromeTest -->
<class name="FirefoxTest">
<test-method status="PASS" signature="beforeTest()[pri:7, 
instance:FirefoxTest@6a2bcfcb]" name="beforeTest" duration-ms="24220" 
started-at="2017-09-12T09:50:43Z" finished-at="2017-09-12T09:51:07Z">
<reporter-output>
</reporter-output>
</test-method> <!-- beforeTest -->
<test-method status="PASS" signature="f()[pri:8, 
instance:FirefoxTest@6a2bcfcb]" name="f" duration-ms="3212" started-
at="2017-09-12T09:51:07Z" finished-at="2017-09-12T09:51:10Z">
<reporter-output>
 </reporter-output>
</test-method> <!-- f -->
<test-method status="PASS" signature="afterTest()[pri:9, 
instance:FirefoxTest@6a2bcfcb]" name="afterTest" duration-ms="83" 
started-at="2017-09-12T09:51:10Z" finished-at="2017-09-12T09:51:10Z">
<reporter-output>
</reporter-output>
</test-method> <!-- afterTest -->
</class> <!-- FirefoxTest -->
</test> <!-- Default test -->
</suite> <!-- Default suite -->
</testng-results>

2 个答案:

答案 0 :(得分:0)

Jenkins只是在命令行中触发测试,然后就像你提到解析并显示xml结果文件一样。 试着用Jenkins运行它,说使用Maven,你看到它失败了吗?如果是这样,问题与Jenkins本身无关,我将专注于测试代码本身

答案 1 :(得分:0)

我通过使用Maven和Junit测试工具解决了我的问题。 我还在运行测试之前在git中添加了整个项目工作区。 在Jenkins构建运行后,我可以看到每个构建的结果。 谢谢大家的帮助