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

Configure a setUp() method #2

Merged
merged 6 commits into from
Mar 18, 2023
Merged

Configure a setUp() method #2

merged 6 commits into from
Mar 18, 2023

Conversation

kaiosilveira
Copy link
Owner

@kaiosilveira kaiosilveira commented Mar 17, 2023

Chapter 19: Set the table

Our goal in this chapter was to implement a setUp() method, commonly used in test classes to configure repetitive boilerplate in order to run the tests.

Implementation checklist:

Invoke test method
Invoke setUp first
☑️ Invoke tearDown afterward
☑️ Invoke tearDown even if the test method fails
☑️ Run multiple tests
☑️ Report collected results

Closes #5

@kaiosilveira kaiosilveira marked this pull request as draft March 17, 2023 21:05
@kaiosilveira kaiosilveira changed the base branch from main to chapter18/first-steps-to-xunit March 18, 2023 08:20
@kaiosilveira kaiosilveira force-pushed the chapter18/first-steps-to-xunit branch 6 times, most recently from 3c77585 to bf17e19 Compare March 18, 2023 09:54
@kaiosilveira kaiosilveira force-pushed the chapter19/set-the-table branch 6 times, most recently from 01b50f8 to ec22cf5 Compare March 18, 2023 10:38
Checklist:
- Invoke setUp first 👈🏼
- Invoke tearDown afterward
- Invoke tearDown even if the test method fails
- Run multiple tests
- Report collected results

---

Output:
➜ python3 src/TestCaseTest.py
Traceback (most recent call last):
  File "tdd-xunit-example/src/TestCaseTest.py", line 19, in <module>
    TestCaseTest("testSetup").run()
  File "tdd-xunit-example/src/TestCase.py", line 8, in run
    method()
  File "tdd-xunit-example/src/TestCaseTest.py", line 15, in testSetup
    assert (test.wasSetUp)
            ^^^^^^^^^^^^^
AttributeError: 'WasRun' object has no attribute 'wasSetUp'
Checklist:
- Invoke setUp first 👈🏼
- Invoke tearDown afterward
- Invoke tearDown even if the test method fails
- Run multiple tests
- Report collected results

---

Output:
➜ python3 src/TestCaseTest.py
Traceback (most recent call last):
  File "tdd-xunit-example/src/TestCaseTest.py", line 19, in <module>
    TestCaseTest("testSetup").run()
  File "tdd-xunit-example/src/TestCase.py", line 8, in run
    method()
  File "tdd-xunit-example/src/TestCaseTest.py", line 15, in testSetup
    assert (test.wasSetUp)
            ^^^^^^^^^^^^^
AttributeError: 'WasRun' object has no attribute 'wasSetUp'
Checklist:
- Invoke setUp first 👈🏼
- Invoke tearDown afterward
- Invoke tearDown even if the test method fails
- Run multiple tests
- Report collected results
Checklist:
- Invoke setUp first 👈🏼
- Invoke tearDown afterward
- Invoke tearDown even if the test method fails
- Run multiple tests
- Report collected results

---

Output:
➜ python3 src/TestCaseTest.py
Traceback (most recent call last):
  File "tdd-xunit-example/src/TestCaseTest.py", line 18, in <module>
    TestCaseTest("testRunning").run()
  File "tdd-xunit-example/src/TestCase.py", line 12, in run
    method()
  File "tdd-xunit-example/src/TestCaseTest.py", line 8, in testRunning
    assert (not test.wasRun)
                ^^^^^^^^^^^
AttributeError: 'WasRun' object has no attribute 'wasRun'
Checklist:
- Invoke setUp first 👈🏼
- Invoke tearDown afterward
- Invoke tearDown even if the test method fails
- Run multiple tests
- Report collected results
Checklist:
- Invoke setUp first ✅
- Invoke tearDown afterward
- Invoke tearDown even if the test method fails
- Run multiple tests
- Report collected results
@kaiosilveira kaiosilveira marked this pull request as ready for review March 18, 2023 11:17
@kaiosilveira kaiosilveira linked an issue Mar 18, 2023 that may be closed by this pull request
@kaiosilveira kaiosilveira changed the base branch from chapter18/first-steps-to-xunit to main March 18, 2023 11:34
@kaiosilveira kaiosilveira merged commit 7bc9bd9 into main Mar 18, 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 19: Set the table
1 participant