首页 > 解决方案 > 如何在 wdio junit 报告器 xml 报告中显示跳过的消息

问题描述

我正在使用带有 Cucumber 集成的 WDIO 浏览器测试功能。我已经定义了一个功能文件,将其中一个测试场景标记为“@skipped”。我已经处理了步骤定义文件中的场景以跳过带有给定标签的测试。报告(与 Jenkins 兼容的 Junit xml 报告)也反映了相同的情况,但是我还想添加跳过的消息(根据架构跳过的消息支持https://llg.cubic.org/docs/junit/)。谁能帮我添加跳过的消息?

这是功能文件代码片段

Feature: Add a Todo
    In order to create Todo items
    As a user
    I want to be able to add a Todo item to the list of current items

    Scenario: Add to the initial set
        Given I have 3 Todo's
        When I add one
        Then the total number of Todo's should be 4

    @skipped
    Scenario: Edit a todo
        Given Todo's title is "foo" and description is "foo"
        When I edit one
        Then the total number of Todo's post edit should be 4

这是跳过测试的步骤定义片段

Before({tags: '@skipped'}, function() {
    console.log('>>> skipped');
    return "skipped";
  });

这是xml报告

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="Add_a_Todo" timestamp="2021-08-04T06:18:15" time="9.555" tests="2" failures="0" errors="0" skipped="1">
    <properties>
      <property name="specId" value="0"/>
      <property name="featureName" value="Add a Todo"/>
      <property name="capabilities" value="chrome.71_0_3578_80.linux"/>
      <property name="featureFile" value="./features/Todo.feature"/>
    </properties>
    <testcase classname="CucumberJUnitReport-chrome.71_0_3578_80.linux.Add_a_Todo" name="Add_a_Todo.Add_to_the_initial_set" time="9.519">
      <system-out>
        <![CDATA[
✅ Given I have 3 Todo's✅ When I add one✅ Then the total number of Todo's should be 4

]]>
      </system-out>
    </testcase>
    <testcase classname="CucumberJUnitReport-chrome.71_0_3578_80.linux.Add_a_Todo" name="Add_a_Todo.Edit_a_todo" time="0.014">
      <skipped/>
      <system-out>
        <![CDATA[
⚠️ Given Todo's title is "foo" and description is "foo"
⚠️ When I edit one
⚠️ Then the total number of Todo's post edit should be 4
]]>
      </system-out>
    </testcase>
  </testsuite>
</testsuites>

标签: javascripttestingcucumberbrowser-testingwdio-v6

解决方案


推荐阅读