jenkins - Behat、JUnit 和 Jenkins
问题描述
试图将 Behat 结果解释为 JUnit 报告时,我有点发疯了。
我正在使用 ant 构建来生成测试结果,这就是它的调用方式:
<target name="behat" description="Run Behat Scenarios">
<exec executable="php">
<arg value="vendor/behat/behat/bin/behat" />
<arg value="--format" />
<arg value="pretty" />
<arg value="--out" />
<arg value="std" />
<arg value="--format" />
<arg value="junit" />
<arg value="--out" />
<arg value="${basedir}/build/logs/" />
</exec>
</target>
这是 Jenkins 的控制台输出:
INFO: Processing JUnit
INFO: [JUnit] - 1 test report file(s) were found with the pattern 'build/logs/default.xml' relative to '/var/lib/jenkins/workspace/Web-Analysis' for the testing framework 'JUnit'.
WARNING: The file '/var/lib/jenkins/workspace/Web-Analysis/build/logs/default.xml' is an invalid file.
WARNING: At line 4 of file:/var/lib/jenkins/workspace/Web-Analysis/build/logs/default.xml:cvc-complex-type.3.2.2: Attribute 'status' is not allowed to appear in element 'testcase'.
WARNING: At line 5 of file:/var/lib/jenkins/workspace/Web-Analysis/build/logs/default.xml:cvc-complex-type.3.2.2: Attribute 'status' is not allowed to appear in element 'testcase'.
ERROR: The plugin hasn't been performed correctly: The result file '/var/lib/jenkins/workspace/Web-Analysis/build/logs/default.xml' for the metric 'JUnit' is not valid. The result file has been skipped.
这是生成的 JUnit 文件:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="default">
<testsuite name="Testing" tests="2" skipped="0" failures="0" errors="0" time="0">
<testcase name="Home Page" status="passed" time="0"></testcase>
<testcase name="Dashboard is locked to guests" status="passed" time="0"></testcase>
</testsuite>
</testsuites>
我已经看到了一些与之相关的问题,但无法真正找到有关如何解决此问题的答案。任何帮助将不胜感激,如果需要,我很乐意提供更多详细信息!如果有帮助,我正在使用 Behat 3.5.0。
--edit 只需添加 behat.yml 和控制台输出
default:
gherkin:
cache: ~
extensions:
Laracasts\Behat\ServiceContainer\BehatExtension: ~
Behat\MinkExtension\ServiceContainer\MinkExtension:
default_session: laravel
laravel: ~
behat:
[exec] Feature: Testing
[exec] In order to learn Behat
[exec] As a developer
[exec] I want to learn how to install and create features
[exec]
[exec] Scenario: Home Page # features/example.feature:6
[exec] Given I am on the homepage # FeatureContext::iAmOnHomepage()
[exec] Then I should see "Audio" # FeatureContext::assertPageContainsText()
[exec]
[exec] Scenario: Dashboard is locked to guests # features/example.feature:10
[exec] When I go to "admin" # FeatureContext::visit()
[exec] Then the url should match "login" # FeatureContext::assertUrlRegExp()
[exec] And I can do something with Laravel # FeatureContext::iCanDoSomethingWithLaravel()
[exec]
[exec] 2 scenarios (2 passed)
[exec] 5 steps (5 passed)
[exec] 0m0.14s (22.99Mb)
解决方案
在将 Jenkins xUnit 插件升级到 2.2.3(从 2.0.0)后,我遇到了这个问题,降级到 2.0.0“解决了”这个问题。
推荐阅读
- firebase - Facebook 登录弹出窗口不会显示在我的 React Native Expo 应用程序上(使用 Firebase)
- python - 如何在django的博客文章中指定用户?
- javascript - 拖动一个矩形并附加到相应的组
- azure-ad-b2c - B2C 自定义策略中的“CreateRandomString”函数问题
- python - 如何获取python中字符串出现的计数?
- python - Jupyter 安装失败
- javascript - 当我的 React 和 Node 服务器不同(Firebase)时,我遇到 Passport 问题,但当它们相同时(Heroku)没有问题
- c# - 文本框和 Datagridview 组合然后发送到 Mysql C# VisualStudio 代码
- ruby-on-rails-5 - Rails - 以自身为条件的哈希合并
- sql - Oracle SQL 子字符串