HtmlTestRunner icon indicating copy to clipboard operation
HtmlTestRunner copied to clipboard

How to combine HTMLTestRunner with nosetests?

Open danschef opened this issue 7 years ago • 4 comments

  • HtmlTestRunner version: 1.1.1
  • Python version: 3.6
  • Operating System: Ubuntu Linux

Description

I tried out your example on the main page including the

    if __name__ == '__main__':
        unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='example_dir'))

and ran it as suggested with 'python test.py' which works fine and generates a nice HTML report.

However, i was wondering if there is any possibility to combine HTMLTestRunner with nosetests.

I tried the following:

>>> nosetests tests/test_HTMLTestRunner.py -vv
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
This test should be marked as error one. ... ERROR
This test should fail. ... FAIL
test_isupper (tests.test_HTMLTestRunner.TestStringMethods) ... ok
This test should be skipped. ... SKIP: This is a skipped test.
test_split (tests.test_HTMLTestRunner.TestStringMethods) ... ok
test_upper (tests.test_HTMLTestRunner.TestStringMethods) ... ok

======================================================================
ERROR: This test should be marked as error one.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/testproject/tests/test_HTMLTestRunner.py", line 24, in test_error
    raise ValueError
ValueError

======================================================================
FAIL: This test should fail.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/testproject/tests/test_HTMLTestRunner.py", line 28, in test_fail
    self.assertEqual(1, 2)
AssertionError: 1 != 2

----------------------------------------------------------------------
Ran 6 tests in 0.003s

FAILED (SKIP=1, errors=1, failures=1)

So the tests are working as expected but no HTML outputs are generated. Do you have a suggestion how to get this to work?

danschef avatar Jul 21 '17 14:07 danschef

Hi, I haven't tested it with nose test, I will research it and let you know.

oldani avatar Jul 26 '17 00:07 oldani

Thanks! It would really nice to combine it with nosetests!

danschef avatar Jul 26 '17 10:07 danschef

Hi, Is nose-test is updated with Htmltestrunner for generating coverage report of testcase module?

priya022 avatar Feb 20 '18 13:02 priya022

no yet, now that I have free time I will look how to hook htmltestrunner with nose

oldani avatar Feb 27 '18 21:02 oldani