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 collected results #9

Merged
merged 8 commits into from
Mar 18, 2023
Merged

Report collected results #9

merged 8 commits into from
Mar 18, 2023

Commits on Mar 18, 2023

  1. assert for result.summary at testTemplateMethod()

    This change will enable us to display a visual report of the tests being run, so we can give feedback to users (instead of the program just blankly finishing)
    
    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report collected results 👈🏼
    
    ---
    
    Output:
    ➜ python3 src/test_case_test.py
    Traceback (most recent call last):
      File "tdd-xunit-example/src/test_case_test.py", line 12, in <module>
        TestCaseTest("testTemplateMethod").run()
      File "tdd-xunit-example/src/test_case.py", line 12, in run
        method()
      File "tdd-xunit-example/src/test_case_test.py", line 9, in testTemplateMethod
        assert ("1 run, 0 failed" == result.summary())
                                     ^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'summary'
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    7e487a8 View commit details
    Browse the repository at this point in the history
  2. introduce a TestResult class with hardcoded impl

    This class will be used to hold a summary of the test suite execution. For now, though, it's just implementing a summary method with a hardcoded implementation.
    
    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report collected results 👈🏼
    
    ---
    
    Output:
    ➜ python3 src/test_case_test.py
    Traceback (most recent call last):
      File "tdd-xunit-example/src/test_case_test.py", line 12, in <module>
        TestCaseTest("testTemplateMethod").run()
      File "tdd-xunit-example/src/test_case.py", line 12, in run
        method()
      File "tdd-xunit-example/src/test_case_test.py", line 9, in testTemplateMethod
        assert ("1 run, 0 failed" == result.summary())
                                     ^^^^^^^^^^^^^^
    AttributeError: 'NoneType' object has no attribute 'summary'
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    2475871 View commit details
    Browse the repository at this point in the history
  3. return an instance of TestResult at TestCase.run()

    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report collected results 👈🏼
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    e744108 View commit details
    Browse the repository at this point in the history
  4. introduce symbolic constant runCount

    This instance variable will be used to hold the number of tests there were ran in a test session. For now, though, it is hardcoded to the value 1.
    
    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report collected results 👈🏼
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    4334eaf View commit details
    Browse the repository at this point in the history
  5. implement testStarted() at TestResult

    This method will be responsible for updating the value of runCount everytime a test is executed
    
    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report collected results 👈🏼
    
    ---
    
    Output:
    ➜ python3 src/test_case_test.py
    Traceback (most recent call last):
      File "tdd-xunit-example/src/test_case_test.py", line 12, in <module>
        TestCaseTest("testTemplateMethod").run()
      File "tdd-xunit-example/src/test_case.py", line 15, in run
        method()
      File "tdd-xunit-example/src/test_case_test.py", line 9, in testTemplateMethod
        assert ("1 run, 0 failed" == result.summary())
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AssertionError
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    69d2a11 View commit details
    Browse the repository at this point in the history
  6. update TestCase.run() to call TestResult.testStarted()

    This call is needed so we can increment the runCount variable and compute the number of tests ran in a session
    
    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report collected results 👈🏼
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    5d7469b View commit details
    Browse the repository at this point in the history
  7. add test for a failed test report

    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report collected results 👈🏼
    
    ---
    
    Output:
    ➜ python3 src/test_case_test.py
    Traceback (most recent call last):
      File "tdd-xunit-example/src/test_case_test.py", line 18, in <module>
        TestCaseTest("testFailedResult").run()
      File "tdd-xunit-example/src/test_case.py", line 17, in run
        method()
      File "tdd-xunit-example/src/test_case_test.py", line 13, in testFailedResult
        result = test.run()
                 ^^^^^^^^^^
      File "tdd-xunit-example/src/test_case.py", line 16, in run
        method = getattr(self, self.name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'WasRun' object has no attribute 'testBrokenMethod'
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    751d37d View commit details
    Browse the repository at this point in the history
  8. implement testBrokenMethod() at WasRun

    This implementation will support the code being executed as part of TestCase.testFailedResult. For now, though, we're just raising an exception.
    
    Checklist:
    - Invoke tearDown even if the test method fails
    - Run multiple tests
    - Report collected results ✅
    
    ---
    
    Output:
    ➜ python3 src/test_case_test.py
    Traceback (most recent call last):
      File "tdd-xunit-example/src/test_case_test.py", line 18, in <module>
        TestCaseTest("testFailedResult").run()
      File "tdd-xunit-example/src/test_case.py", line 17, in run
        method()
      File "tdd-xunit-example/src/test_case_test.py", line 13, in testFailedResult
        result = test.run()
                 ^^^^^^^^^^
      File "tdd-xunit-example/src/test_case.py", line 17, in run
        method()
      File "tdd-xunit-example/src/was_run.py", line 20, in testBrokenMethod
        raise Exception
    Exception
    kaiosilveira committed Mar 18, 2023
    Configuration menu
    Copy the full SHA
    47adee2 View commit details
    Browse the repository at this point in the history