Skip to content

Conversation

@kaiosilveira
Copy link
Owner

@kaiosilveira kaiosilveira commented Mar 18, 2023

Chapter 23: How suite it is

Our goal in this chapter was to implement a test suite. We accomplished that by introducing the TestSuite class and making some changes in order to make it look like a TestCase, using the composite pattern.

Implementation checklist:

Invoke tearDown afterward
☑️ Invoke tearDown even if the test method fails
Run multiple tests
Report collected results
Report failed tests
Catch and report setUp errors

Closes #13

Checklist:
- Invoke tearDown even if the test method fails
- Run multiple tests 👈🏼

---

Output:
➜ python3 src/test_case_test.py
1 run, 0 failed
1 run, 0 failed
1 run, 0 failed
1 run, 0 failed
1 run, 1 failed
Checklist:
- Invoke tearDown even if the test method fails
- Run multiple tests 👈🏼

---

Output:
➜ python3 src/test_case_test.py
1 run, 0 failed
1 run, 0 failed
1 run, 0 failed
1 run, 0 failed
1 run, 1 failed
Checklist:
- Invoke tearDown even if the test method fails
- Run multiple tests 👈🏼

---

Output:
➜ python3 src/test_case_test.py
1 run, 0 failed
1 run, 0 failed
1 run, 0 failed
1 run, 0 failed
1 run, 1 failed
This is needed because we want to aggregate all the results in the same `TestResult` instance.

Checklist:
- Invoke tearDown even if the test method fails
- Run multiple tests 👈🏼

---

Output:
➜ python3 src/test_case_test.py
1 run, 0 failed
1 run, 0 failed
1 run, 0 failed
1 run, 0 failed
1 run, 1 failed
@kaiosilveira kaiosilveira force-pushed the chapter23/how-suite-it-is branch from 5a8b92f to 179758c Compare March 19, 2023 08:24
Checklist:
- Invoke tearDown even if the test method fails
- Run multiple tests 👈🏼

---

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>
    print(TestCaseTest("testTemplateMethod").run().summary())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TestCase.run() missing 1 required positional argument: 'result'
Checklist:
- Invoke tearDown even if the test method fails
- Run multiple tests 👈🏼

---

Output:
➜ python3 src/test_case_test.py
5 run, 4 failed
Checklist:
- Invoke tearDown even if the test method fails
- Run multiple tests 👈🏼

---

Output:
➜ python3 src/test_case_test.py
5 run, 0 failed
Checklist:
- Invoke tearDown even if the test method fails
- Run multiple tests ✅

---

Output:
➜ python3 src/test_case_test.py
5 run, 0 failed
@kaiosilveira kaiosilveira marked this pull request as ready for review March 19, 2023 08:28
@kaiosilveira kaiosilveira force-pushed the chapter23/how-suite-it-is branch from 179758c to 2ca814b Compare March 19, 2023 08:28
@kaiosilveira kaiosilveira merged commit 2ae5df8 into main Mar 19, 2023
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

Successfully merging this pull request may close these issues.

Chapter 23: How suite it is

2 participants