I've seen this question: py.test logging messages and test results/assertions into a single file I've also read documentation here: https://docs.pytest.org/en/latest/logging.html
Neither comes close to a satisfactory solution.
test-name PASSED
). It's OK if the summary also contains the stack trace for failing tests, but it's not essential.I tried pytest-logs
plugin. As far as I can tell, it can override some default pytest
behavior by displaying all logging while the test runs. This is slightly better than default behavior, but it's still very far from what I need. From the documentation I understand that pytest-catchlog
will conflict with pytest
, and I don't even want to explore that option.
Is this achievable by configuring pytest
or should I write a plugin, or, perhaps, even a plugin won't do it, and I will have to patch pytest
?
You can use --junit-xml=xml-path
switch to generate junit logs. If you want the report in html format, you can use pytest-html plugin. Similarly, you can use pytest-excel plugin to generate report in excel format.
You can use tee to pipe logs to two different processes. example: pytest --junit-xml=report.xml | tee log_for_testers.log
It will generate logs in stdout for CI log, report.xml for CI artifact and log_for_testers.log for team analysis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With