Skip to content

Test Cases in Test Suites Being Overwritten #4

Closed
@kimfucious

Description

@kimfucious

Hi there,

Nice work on this. It looks great!

tl;dr

❓ is there a way to generate a single report covering multiple test cases in a test suite?
❓ Bonus question: if the above is possible, can each test sweet have it's own section within the report?

Detailed Description

I'm probably doing something dumb, but I'm seeing some unexpected behavior when running the tests, using a test suite.

In short, running a report when there are many test cases results in:

Generating HTML reports...
Template is not specified, load default template instead.
Template is not specified, load default template instead.
Template is not specified, load default template instead.
Reports generated: /path/reports/2018-08-17-16-37-21.html, /path/reports/2018-08-17-16-37-21.html, /path/reports/2018-08-17-16-37-22.html

🤔 side question: where are the templates and/or how to your create and use them?

From the above, it looks like the reports are overwriting themselves:

  • 2018-08-17-16-37-21.html
  • 2018-08-17-16-37-21.html
  • 2018-08-17-16-37-22.html

If I define a report name kwargs, only one report is generated with the results of only one test case.

There are a couple scenarios:

  1. Two test cases in a suite. Only the last one is displayed in the report:

  2. Three test cases in the suite, with one of them being skipped, only the skipped test case shows in the report, even though that's not the last test case being run.

The code is below. I test between scenarios by interchanging bst, which is the skipped test case:

suite = unittest.TestSuite([anagrams, capitalize])
suite = unittest.TestSuite([anagrams, bst, capitalize])

runner.py

import unittest
from pyunitreport import HTMLTestRunner
from tests.test_anagrams import AnagramsTests
from tests.test_bst import BinarySearchTreeTests
from tests.test_capitalize import CapitalizeTests

loader = unittest.TestLoader()
anagrams = loader.loadTestsFromTestCase(AnagramsTests)
bst = loader.loadTestsFromTestCase(BinarySearchTreeTests)
capitalize = loader.loadTestsFromTestCase(CapitalizeTests)

suite = unittest.TestSuite([anagrams, bst, capitalize])

kwargs = {
    "output": ""
}

runner = HTMLTestRunner(**kwargs)
runner.run(suite)

One thing that I haven't done is modify the test files individually. Each of them have the following:

if __name__ == "__main__":
    unittest.main()

I've got like fifty test files, so before I go off and change them all, I thought I'd ask.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions