Behat、JUnit 和 Jenkins

Behat, JUnit and Jenkins

尝试将 Behat 结果解释为 JUnit 报告时,我有点发疯了。

我正在使用 ant build 来生成测试结果,这是它的调用方式:

<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。

--编辑 只需添加 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 后遇到了这个问题 "solved" 问题。