Skip to content

Junitxml plugin indicates a xfailed test as a skipped test #7009

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

Closed
harmin-parra opened this issue Apr 3, 2020 · 6 comments
Closed

Junitxml plugin indicates a xfailed test as a skipped test #7009

harmin-parra opened this issue Apr 3, 2020 · 6 comments
Labels
plugin: junitxml related to the junitxml builtin plugin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@harmin-parra
Copy link
Contributor

Environment
platform linux -- Python 3.6.9, pytest-5.4.0, py-1.8.1, pluggy-0.13.1

My test has this fixture
@pytest.mark.xfail(reason="my reason")

Execution command
pytest --junixml=report.xml

Result
The xfailed test is indicated as an skipped test in the junit XML report.

It should be reported as a failed test.

I want my Jenkins test job status to be failed instead of passed.

@harmin-parra harmin-parra changed the title Junitxml modules indicates an xfailed test as an skipped test Junitxml plugin indicates an xfailed test as an skipped test Apr 3, 2020
@harmin-parra harmin-parra changed the title Junitxml plugin indicates an xfailed test as an skipped test Junitxml plugin indicates a xfailed test as a skipped test Apr 3, 2020
@The-Compiler
Copy link
Member

Could you explain a bit more about your usecase? The whole point about marking a test as xfailed is that it doesn't count as failed, no?

@harmin-parra
Copy link
Contributor Author

harmin-parra commented Apr 3, 2020

From pytest point of view, I can understand that you want the xfail test to be considered as not failed.

But it bothers me that in the junit XML report it is considered as skipped and that the overall jenkins job status is considered as passed.

When people see the jenkins job status as passed, they don't bother to see the detailed report in order to find out that there is in fact an xfail test.

@Zac-HD Zac-HD added plugin: junitxml related to the junitxml builtin plugin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature labels Apr 4, 2020
@anonyknight
Copy link

As far as I know, junit report did not include xfail and xpass definition. That's why we can see Jenkinc junit-plugin has no xfail and xpass counter.

https://github.com/jenkinsci/junit-plugin/blob/master/src/main/java/hudson/tasks/junit/TestResultSummary.java

http://doc.pytest.org/en/latest/skipping.html
This test will run but no traceback will be reported when it fails. Instead, terminal reporting will list it in the “expected to fail” (XFAIL) or “unexpectedly passing” (XPASS) sections.

If the test passed, pytest reports xPass in this case, but Pass in junit.xml. If the test failed, then pytest reports xfail but junit.xml reports skipped.

@webknjaz
Copy link
Member

webknjaz commented Jun 5, 2020

@anonyknight it looks like this is the symptom of the fact that pytest treats a test report as xfail/xpass only if it has outcome='skipped' and wasxfail='...' attrs. And it processes them when outputting terminal report: #7327. Other plugins would need to repeat the same logic.

@nicoddemus
Copy link
Member

Unfortunately the JUnit XML format doesn't have the notion of xfail/xpass, so there isn't much that pytest can do here.

@Zac-HD
Copy link
Member

Zac-HD commented Jun 20, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: junitxml related to the junitxml builtin plugin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

6 participants