Why does PyCharm generate a more detailed XML test report than that generated by junit in the terminal?

40 views Asked by At

I'm quite new to PyTest but I've been using PyCharm for running tests. I have loggers in my test functions that can be displayed for all Passed or Failed tests in reports manually generated by PyCharm. However, if I used the --junitxml="results.xml" pytest command in the terminal, it generates a pretty simplified data, with no stderr or stdout logs for Passed ones. What does PyCharm use to generate its XML file?

I have also tried changing to junit_family=xuit1 in pytest.ini but it does not work for me.

Is there any other way to generate a more detailed XML test report via terminal command, specifically that can display stderr and stdout logs in Passed tests? Much like how PyCharm generates its XML report.

1

There are 1 answers

0
10ktech-qa On BEST ANSWER

I inspected the HTML report generated manually from PyCharm and noticed that it has a container of json data. That answers my question.

I installed the pytest-json-report package and used the command "pytest --json-report" to generate a json report file after pytest runs. The json data contains useful information, and including stdout for every tests, failed or passed. Marking this as the answer.