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

htmlrunner report does not display passed subtests using unittest (selenium+python). #12

Closed
ankurgupta02 opened this issue Apr 7, 2019 · 5 comments

Comments

@ankurgupta02
Copy link

htmlrunner report does not display passed subtests using unittest (selenium+python).
Can anyone help me?

I have created a method which iterates multiple times for all links available on webpage. Also, validating the links url (current and expected) via assertion. htmlrunner generating the report for all those link whose urls are not equal but I want that htmlrunner report should also generate for passed links as well.

Thanks in advance.

@nicoddemus
Copy link
Member

Hi @ankurgupta02,

By htmlrunner you mean pytest-html or something else?

Each plugin will probably need to handle sub-tests specifically, I'm afraid.

@ankurgupta02
Copy link
Author

ankurgupta02 commented Apr 10, 2019

Hi @nicoddemus

First of all thank you for replying.

As you mentioned here #7
“It says above that it executed 1 test, but reported 2 failures. We actually have 5 sub-tests, with 3 of them passing and 2 failures, but the passing sub-tests don't count towards the summary. I followed the same approach to reporting for the subtests fixture, even though I agree it is a bit odd.”

I have 2 questions here:

  1. Can we get passed subtests in report?
  2. I got 2 error in report but assertion error (1 != 0) is same for both error. why?
  3. Is there any other way to get the passed result in report?

Run below code then html report give only 2 errors but I was expecting passing result for I=2, I=4 Is it possible?

import unittest
import HtmlTestRunner

class T(unittest.TestCase):

    def test_foo(self):
        for i in range(5):
            with self.subTest():
                self.assertEqual(i % 2, 0)

if __name__ == "__main__":
    unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='C:/Reports'))

Kindly suggest. Thanks in advance.
Capture

@nicoddemus
Copy link
Member

Hi @ankurgupta02,

Can we get passed subtests in report?

I suppose you mean TestCase.subTest, as opposed to the subTest fixture. Not sure, I will need to check how the HTMLReport works (never used before).

I got 2 error in report but assertion error (1 != 0) is same for both error. why?

That's the result from a module division by 2 (aka the rest of the division), you will always get either 1 or 0, so that's correct.

Is there any other way to get the passed result in report?

I'm afraid the answer is the same as the 1st question.

Run below code then html report give only 2 errors but I was expecting passing result for I=2, I=4 Is it possible?

Just to confirm, are you running it with pytest or directly with python? I ask because you have a unittest.main() call in there, and that is meant to be used with python.

@ankurgupta02
Copy link
Author

Simply running via terminal with command:
python -m

@nicoddemus
Copy link
Member

@ankurgupta02 oh then this has absolutely nothing to do with pytest or this plugin, sorry. I suggest you post your issue to the HtmlTestRunner repository. Good luck!

I'm closing this then. 👍

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