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

How to see total tests passed in the summary in pytest-html version 4.1.1 if only failed tests are shown in the summary table #794

Open
bhawna0612 opened this issue Jan 23, 2024 Discussed in #793 · 3 comments

Comments

@bhawna0612
Copy link

Discussed in #793

Originally posted by bhawna0612 January 19, 2024
Hi I upgraded pytest-html version from v3.2.0 to v4.1.1 and I am showing only failed tests in the table.
But in the latest version, it doesn't show the total tests ran, passed count etc. It only shows the failed tests count and duration.

Please see the images for better understanding. I ran the same test suite and different report type is generated.
V3.2.0 is providing more clear picture

V3.2.0

image

V4.1.1
2 tests didn't take 6 mins 25 sec. 13 tests took that much time which is comparable with 386.78 seconds mentioned in v3.2.0

image

How to achieve the same type of report as in v3.2.0?

For reference I am using this hook

image

@bhawna0612
Copy link
Author

Hi Can someone point me that something is wrong in pytest-html version or I am doing something wrong?

@jeffwright13
Copy link
Collaborator

Can you provide us with your actual test code, and how you run them (i.e. what command line options, etc.)? It's a lot easier to troubleshoot if there is a way of reproducing the issue.

@bhawna0612
Copy link
Author

bhawna0612 commented Jan 25, 2024

I have provided already everything here #793 (reply in thread) Please take a look.

The test code which I am running is provided
Commands which I am passing is provided
The Terminal output is provided
The pytest-html hook is provided which I am using is provide where I am skipping the Passed and skipped test cases to be shown in summary table.

Repeating everything again here

The Source code file name is test_login.py under folder test_cases
The source code is content of test_login.py file:

class TestLogin:

    def test_login(self):

        print("test_valid_login")

        assert 1 == 1


   def test_invalid_login(self):

        print("test_invalid_login")

        assert 0 == 1

I have downloaded the html pytest version 4.1.1

This is the hook I am using to remove the passed tests from the results table. This hook is passed in Conftest.py file

def pytest_html_results_table_row(report, cells):

 if report.passed:

 del cells[:]

 elif report.skipped:

 del cells[:]

This is the command I am passing
pytest .\test_cases\test_login.py --html report2.html

Pytest is collecting 2 tests and this is the terminal output. 1 failed, 1 passed

platform win32 -- Python 3.11.7, pytest-7.1.3, pluggy-1.3.0
rootdir: E:\git_repos\web-automation, configfile: pytest.ini
plugins: html-4.1.1, metadata-3.0.0, order-1.0.1, ordering-0.6, xdist-3.3.1
collected 2 items                                                                                                                                                                                                                   

test_cases\test_login.py .F  

and this is the output I got. It doesn't show the count of passed tests.

image

This is pytest.ini file content

[pytest]

filterwarnings =

 ignore::pytest.PytestCacheWarning

render_collapsed = True

Just wondering what else could be needed to reproduce or I am misunderstanding something?

and I was expecting to have result like this so that even though passed tests are removed from the results table, but I would like to still see the total count of tests executed and how many have passed. Something like we have in version 3.2.0

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants