当前位置: 首页 > 知识库问答 >
问题:

Jenkins中的TestNG结果显示通过,即使脚本被更改以生成失败的结果

卜高超
2023-03-14

我已经在一个git分支中上传了testng-results.xml,并且正在使用git存储库作为Jenkins工作的工作区。

因为我在Jenkins上运行的测试是回归测试,所以我希望TestNG报告在任何情况下都会发生变化,存在回归缺陷。我注意到Jenkins上显示的TestNG报告只是testng-results.xml文件的可读版本,即它是我工作区中testng-results.xml文件的精确副本。

我已经将测试脚本chrometest.f()改为故意失败,但Jenkins中的TestNG结果仍然将其标记为通过,如下图所示:

请在下面找到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>

共有1个答案

汪兴为
2023-03-14

Jenkins只是在命令行中触发测试,然后像您提到的那样解析并显示xml结果文件。尝试在Jenkins中运行它,比如说使用Maven,您是否看到它如预期的那样失败了?如果是这样,这个问题与Jenkins本身无关,我将集中讨论测试代码本身

 类似资料:
  • 我正在使用Ant构建我的项目并运行testng测试。我使用jenkins调用Ant目标来运行TestNG测试。还安装了TestNG插件在jenkins上运行在我的项目所在的同一台机器上。 在完成Jenkins的工作时,我得到了跟踪和TestNG结果没有生成。

  • 而且,如果从Eclipse运行这样的测试,即使测试被移除,当套件完成时,失败仍然会打印在日志中。 关于RetryAnalyzer:我根本不考虑使用RetryAnalyzer的良好/最佳实践,但如果您发现自己处于需要解决问题的情况下,例如,您继承了一个依赖RetryAnalyzer的测试套件,您可能会发现这很有用。

  • 我可以通过“诱惑力发球”或“诱惑力发球诱惑力-结果”得到预期的诱惑力报告。但当我想把它部署在詹金斯时,问题就来了。报告是南...和jenkins控制台显示的命令是“allure generate allure-results-c-o allure-report-path”。有人遇到过同样的问题吗?

  • 问题内容: 我正在尝试为我的Qt单元测试项目使用Jenkins xUnit插件,但是我无法使其工作… 这是我到目前为止所做的: 首先,我使用qmakebuilder插件构建我的单元测试项目(向qmakebuilder插件提供.pro),然后添加构建部分,首先在其中放置testResult xml文件,然后运行测试带有标志的二进制文件,以使其为我生成xml文件,然后将xml文件命名为: 最后,在Po

  • 问题内容: 我正在使用Jenkins构建我的Maven项目并使用插件发布testng结果。报告中的西里尔符号有问题。看起来像: 。但是在Jenkins控制台中的西里尔文输出是可以的。 我的pom.xml: 项目编码设置为UTF-8。IDE是Intellij IDEA 12.1.3。TestNG 6.8.5。 问题答案: 其实, 应该修复它。

  • 问题内容: 基本上我想要的是以下代码的工作版本: 错误: 原因: 根据MySQL Doc: 只要服务器运行,InnoDB就会使用内存中的自动增量计数器。如前所述,当服务器停止并重新启动时,InnoDB将为该表的第一个INSERT重新初始化每个表的计数器。 这意味着每当我重新启动服务器时,我的auto_increment值都将设置为最小。 我有一个叫的表,另一个叫的表。他们两个都有共享的列。表格中的