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

implement TestSuite #12

Merged
merged 8 commits into from
Mar 19, 2023
Merged

implement TestSuite #12

merged 8 commits into from
Mar 19, 2023

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
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 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
1 participant