Skip to content

Add suite and test field of skipped test to xml report#14422

Merged
christian-bromann merged 2 commits intowebdriverio:mainfrom
ccharnkij:junit-reporter-suites
Apr 22, 2025
Merged

Add suite and test field of skipped test to xml report#14422
christian-bromann merged 2 commits intowebdriverio:mainfrom
ccharnkij:junit-reporter-suites

Conversation

@ccharnkij
Copy link
Contributor

Proposed changes

My attempt at addressing #14411 and #14374 while keeping #14223.

This is how it will look:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1" errors="0" skipped="0">
  <testsuite tests="1" failures="1" errors="0" skipped="0">
    <testcase classname="" name="">
      <failure message="No tests found"/>
    </testcase>
  </testsuite>
</testsuites>

Tested with Jenkins Junit Plugin 1322.v1556dc1c59a_f
image
image
image

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

@pkg-pr-new
Copy link

pkg-pr-new bot commented Apr 20, 2025

Open in StackBlitz

eslint-plugin-wdio

npm i https://pkg.pr.new/webdriverio/webdriverio/eslint-plugin-wdio@14422

@wdio/allure-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/allure-reporter@14422

@wdio/appium-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/appium-service@14422

@wdio/browser-runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/browser-runner@14422

@wdio/cli

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/cli@14422

@wdio/concise-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/concise-reporter@14422

@wdio/browserstack-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/browserstack-service@14422

@wdio/config

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/config@14422

@wdio/cucumber-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/cucumber-framework@14422

@wdio/dot-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/dot-reporter@14422

@wdio/firefox-profile-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/firefox-profile-service@14422

@wdio/globals

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/globals@14422

@wdio/jasmine-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/jasmine-framework@14422

@wdio/json-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/json-reporter@14422

@wdio/junit-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/junit-reporter@14422

@wdio/lighthouse-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/lighthouse-service@14422

@wdio/local-runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/local-runner@14422

@wdio/logger

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/logger@14422

@wdio/mocha-framework

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/mocha-framework@14422

@wdio/protocols

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/protocols@14422

@wdio/repl

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/repl@14422

@wdio/reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/reporter@14422

@wdio/runner

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/runner@14422

@wdio/sauce-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/sauce-service@14422

@wdio/shared-store-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/shared-store-service@14422

@wdio/smoke-test-cjs-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-cjs-service@14422

@wdio/smoke-test-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-reporter@14422

@wdio/smoke-test-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-service@14422

@wdio/spec-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/spec-reporter@14422

@wdio/static-server-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/static-server-service@14422

@wdio/sumologic-reporter

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/sumologic-reporter@14422

@wdio/testingbot-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/testingbot-service@14422

@wdio/types

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/types@14422

@wdio/utils

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/utils@14422

@wdio/webdriver-mock-service

npm i https://pkg.pr.new/webdriverio/webdriverio/@wdio/webdriver-mock-service@14422

webdriver

npm i https://pkg.pr.new/webdriverio/webdriverio/webdriver@14422

webdriverio

npm i https://pkg.pr.new/webdriverio/webdriverio@14422

commit: b5e8e2f

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document this change.

if (suiteKeys.length === 0) {
const error = this.runnerStat?.error ?? 'No tests found'
return builder.testCase().failure(error)
if (!isCucumberFrameworkRunner || (isCucumberFrameworkRunner && type === 'feature')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate why we need this if statement? Maybe to help have contributors understand what this means, a comment may make sense here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is to make cucumber and mocha result look the same for empty suites. Otherwise, _buildOrderedReport will be ran twice for cucumber (for feature and scenario) and the xml will look like this:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="2" failures="2" errors="0" skipped="0">
  <testsuite tests="1" failures="1" errors="0" skipped="0">
    <testcase classname="" name="">
      <failure message="No tests found"/>
    </testcase>
  </testsuite>
  <testsuite tests="1" failures="1" errors="0" skipped="0">
    <testcase classname="" name="">
      <failure message="No tests found"/>
    </testcase>
  </testsuite>
</testsuites>

which is ok too, if that's the look you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this makes total sense. Let's just add a comment help the next person understand this context because it is almost impossible to do so without this. Just add a comment with the appropriate context information.

@ccharnkij
Copy link
Contributor Author

Let's document this change.

Sure, how would you like me to document this?

@ccharnkij ccharnkij force-pushed the junit-reporter-suites branch from 7f76c64 to 64bfe19 Compare April 21, 2025 23:37
@ccharnkij
Copy link
Contributor Author

@christian-bromann better?

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks 👌

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Apr 22, 2025
@christian-bromann christian-bromann merged commit 7b9ae76 into webdriverio:main Apr 22, 2025
77 of 79 checks passed
@wdio-bot
Copy link
Contributor

Hey ccharnkij 👋

Thank you for your contribution to WebdriverIO! Your pull request has been marked as an "Expensable" contribution.

We've sent you an email with further instructions on how to claim your expenses from our development fund.
Please make sure to check your spam folder as well. If you have any questions, feel free to reach out to us at expense@webdriver.io or in the contributing channel on Discord.

We are looking forward to more contributions from you in the future 🙌

Have a nice day,
The WebdriverIO Team 🤖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Expensable $35 💸 PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants