Closed BradLucky closed 1 year ago
I was just looking for this too! Looks like it was discussed in https://github.com/MishaKav/pytest-coverage-comment/issues/69 and workarounds given there. I'll try those, though I do think the intuitive thing is an option that defaults to True for failing the step on test failure.
teeing the output is like a simple "workaround" to get the comment-report without modifying the workflow too much.
The best thing to do is to use the pytest-xml-coverage-path
(--cov-report "xml:coverage.xml
), in this way you will get the report-comment and fail the action when the pytest will fail or the solutions that provided #69
I have noticed that teeing the output of pytest in order for pytest-coverage-comment to leave a comment means that test failures do not cause the action to show as failed in Github. In fact, it hasn't "failed," since the exit code is swallowed by teeing the output.
I have found two alternatives to address this situation:
Is there a way built in to pytest-coverage-comment to cause the action to fail if there are failures? If not, I feel it would be a worthwhile option. In fact, it's the expected behavior IMHO. I did not know when implementing this commenter that my PRs would suddenly "go green" even when tests failed.