Given-When-Then is borrowed from BDD and is my favorite structure for test case design.
It doesn’t matter if you are using pytest, unittest, nose, or something completely different, this episode will help you write better tests.
The Given-When-Then structure for test method/function development.How and why to utilize fixtures for your given or precondition code.Similarities with other structure discriptions.Setup-Test-TeardownSetup-Excercise-Verify-Teardown.Arrange-Act-AssertPreconditions-Trigger-Postconditions.BenefitsCommunicate the purpose of your test more clearlyFocus your thinking while writing the testMake test writing fasterMake it easier to re-use parts of your testHighlight the assumptions you are making about the test preconditionsHighlight what outcomes you are expecting and testing against.Links discussed in the show:
Mechanics of pytest, unittest, noseunittest fixture referencenose fixture referencepytest fixtures (series of posts starting here)pytest style fixturespytest parameterized fixturesSupport Test & Code - Software Testing, Development, Python