pytest-html
pytest-html copied to clipboard
Is it possible to generate report at the end of each Pytest session
In my Automation Suite, I am running multiple session, but single HTML report is getting generated which contains test report of all the session combined. Is there a way to generate report for each session individually ?
@barnwal-paras When you say "multiple session", do you mean using xdist or multiple calls to pytest or something else?
@BeyondEvil No, I am using a parametrised session scoped fixture and wanted to generate report at the end of every session, as a part of teardown of that fixture.
@barnwal-paras Not sure I follow. Could you give an example in code?
Do you want a report for each session?
@pytest.fixture(scope="session", params=[session1_config, session2_config])
def config(request, chrome_config):
setup()
yield
teardown()
I want report to be generated everytime teardown is called for those set of test having same parameter.
Similar to #254, this would require a major refactor due to the fact that today, the entire report is done in memory until the pytest_sessionfinish hook is called - that's when the writing of the report to disk happens.
One option would be for you to import the HTMLReport class yourself, and add the logic necessary to generate a report for each session.