Skip to content
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

Is it possible to generate report at the end of each Pytest session #256

Open
barnwal-paras opened this issue Jan 10, 2020 · 5 comments
Open
Labels
question This PR is asking whether it is possible to achieve a certain outcome

Comments

@barnwal-paras
Copy link

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 ?

@BeyondEvil
Copy link
Contributor

@barnwal-paras When you say "multiple session", do you mean using xdist or multiple calls to pytest or something else?

@barnwal-paras
Copy link
Author

@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.

@BeyondEvil
Copy link
Contributor

@barnwal-paras Not sure I follow. Could you give an example in code?

Do you want a report for each session?

@barnwal-paras
Copy link
Author

@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.

@BeyondEvil
Copy link
Contributor

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.

@gnikonorov gnikonorov added the question This PR is asking whether it is possible to achieve a certain outcome label Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This PR is asking whether it is possible to achieve a certain outcome
Projects
None yet
Development

No branches or pull requests

3 participants