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

Report failed tests #10

Merged
merged 6 commits into from
Mar 18, 2023
Merged

Report failed tests #10

merged 6 commits into from
Mar 18, 2023

Commits on Mar 18, 2023

  1. add a smaller grained test for result formatting

    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report failed tests 👈🏼
    
    ---
    
    Output:
    ➜ python3 src/test_case_test.py
    Traceback (most recent call last):
      File "tdd-xunit-example/src/test_case_test.py", line 24, in <module>
        TestCaseTest("testFailedResultFormatting").run()
      File "tdd-xunit-example/src/test_case.py", line 17, in run
        method()
      File "tdd-xunit-example/src/test_case_test.py", line 19, in testFailedResultFormatting
        result.testFailed()
        ^^^^^^^^^^^^^^^^^
    AttributeError: 'TestResult' object has no attribute 'testFailed'. Did you mean: 'testStarted'?
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    06c9085 View commit details
    Browse the repository at this point in the history
  2. implement testFailed() at TestResult

    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report failed tests 👈🏼
    
    ---
    
    Output:
    Traceback (most recent call last):
      File "tdd-xunit-example/src/test_case_test.py", line 24, in <module>
        TestCaseTest("testFailedResultFormatting").run()
      File "tdd-xunit-example/src/test_case.py", line 17, in run
        method()
      File "tdd-xunit-example/src/test_case_test.py", line 20, in testFailedResultFormatting
        assert ("1 run, 1 failed" == result.summary())
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AssertionError
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    ed406b6 View commit details
    Browse the repository at this point in the history
  3. report failed test count at TestResult.summary

    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report failed tests 👈🏼
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    458eefe View commit details
    Browse the repository at this point in the history
  4. implement logic to capture exceptions during tests

    There's a subtlety hidden in this implementation: if we have any problems during setUp, our test failure will not be correctly reported. A new item was added to the checklist below to cover this case.
    
    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report failed tests ✅
    - Catch and report setUp errors
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    0d98891 View commit details
    Browse the repository at this point in the history
  5. add test to make sure setUp() errors are caught

    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report failed tests ✅
    - Catch and report setUp errors 👈🏼
    
    ---
    
    Output:
    ➜ python3 src/test_case_test.py
    Traceback (most recent call last):
      File "tdd-xunit-example/src/test_case_test.py", line 39, in <module>
        TestCaseTestWithBrokenSetup("testFailedSetUp").run()
      File "tdd-xunit-example/src/test_case.py", line 15, in run
        self.setUp()
      File "tdd-xunit-example/src/test_case_test.py", line 11, in setUp
        raise Exception
    Exception
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    f15c647 View commit details
    Browse the repository at this point in the history
  6. implement exception handling for setUp()

    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report failed tests ✅
    - Catch and report setUp errors ✅
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    ca7f326 View commit details
    Browse the repository at this point in the history