Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: @wdio/junit-reporter - Both Errors and Failures Incremented for Failed Tests #12710

Open
3 tasks done
ASaiAnudeep opened this issue Apr 17, 2024 · 2 comments
Open
3 tasks done
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested

Comments

@ASaiAnudeep
Copy link
Contributor

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.32.4

Node.js Version

20

Mode

WDIO Testrunner

Which capabilities are you using?

NA

What happened?

The JUnit report incorrectly increments both the "errors" and "failures" counts when a test case fails. Seems, failures and errors are being treated similarly - link

What is your expected behavior?

Only the "failures" count should increase for failed tests. JUnit reports typically distinguish between errors (unexpected exceptions) and failures (asserted conditions not met).

JUnit Schema Links

How to reproduce the bug.

<testsuite name="As a user I can log into the secure area" timestamp="2023-11-01T21:55:07" time="2.554" tests="3" failures="3" errors="3" skipped="0">

Test Case Expected Output Reference

Relevant log output

NA

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues
@ASaiAnudeep ASaiAnudeep added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Apr 17, 2024
@christian-bromann
Copy link
Member

JUnit reports typically distinguish between errors (unexpected exceptions) and failures (asserted conditions not met).

I found the responsible code path here:

if (test.error) {
if (test.error.message){
test.error.message = test.error.message.replace(ansiRegex, '')
}
if (this.options.errorOptions) {
const errorOptions = this.options.errorOptions
for (const key of Object.keys(errorOptions)) {
testCase[key]((test.error as any)[errorOptions[key]])
}
} else {
// default
testCase.error(test.error.message)
}
testCase.standardError(`\n${test.error.stack?.replace(ansiRegex, '')}\n`)
} else {
testCase.error()
}
testCase.failure()

If we can only report failures, and are able to pass in a failure message, I am happy to accept a pull request with necessary changes.

All contributions are welcome.

@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested and removed Needs Triaging ⏳ No one has looked into the issue yet labels Apr 18, 2024
@wdio-bot
Copy link
Contributor

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

3 participants