pytest-dev / pytest-html

Plugin for generating HTML reports for pytest results
Other
691 stars 234 forks source link

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 8 months ago

bhawna0612 commented 8 months ago

Discussed in https://github.com/pytest-dev/pytest-html/discussions/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](https://github.com/pytest-dev/pytest-html/assets/51174633/22aea619-3a73-4c4d-8a33-581f632b3482) 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](https://github.com/pytest-dev/pytest-html/assets/51174633/77906283-8108-4114-84cc-137f04c83333) How to achieve the same type of report as in v3.2.0? For reference I am using this hook ![image](https://github.com/pytest-dev/pytest-html/assets/51174633/0a3343f7-2378-405d-add3-f40459ee6318)
bhawna0612 commented 8 months ago

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

jeffwright13 commented 8 months ago

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 commented 8 months ago

I have provided already everything here https://github.com/pytest-dev/pytest-html/discussions/793#discussioncomment-8194436 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