10: Test Case Design using Given-When-Then from BDD




Test & Code - Software Testing, Development, Python show

Summary: <p>Given-When-Then is borrowed from BDD and is my favorite structure for test case design.</p> <p>It doesn’t matter if you are using pytest, unittest, nose, or something completely different, this episode will help you write better tests.</p> <ul> <li>The Given-When-Then structure for test method/function development.</li> <li>How and why to utilize fixtures for your given or precondition code.</li> <li>Similarities with other structure discriptions. <ul> <li>Setup-Test-Teardown</li> <li>Setup-Excercise-Verify-Teardown.</li> <li>Arrange-Act-Assert</li> <li>Preconditions-Trigger-Postconditions.</li> </ul> </li> <li>Benefits <ul> <li>Communicate the purpose of your test more clearly</li> <li>Focus your thinking while writing the test</li> <li>Make test writing faster</li> <li>Make it easier to re-use parts of your test</li> <li>Highlight the assumptions you are making about the test preconditions</li> <li>Highlight what outcomes you are expecting and testing against.</li> </ul> </li> </ul> <p><strong>Links discussed in the show:</strong></p> <ul> <li><a href="http://pythontesting.net/start-here" rel="nofollow">Mechanics of pytest, unittest, nose</a></li> <li><a href="http://pythontesting.net/framework/unittest/unittest-fixtures/" rel="nofollow">unittest fixture reference</a></li> <li><a href="http://pythontesting.net/framework/nose/nose-fixture-reference/" rel="nofollow">nose fixture reference</a></li> <li><a href="http://pythontesting.net/framework/pytest/pytest-fixtures/" rel="nofollow">pytest fixtures (series of posts starting here)</a></li> <li><a href="http://pythontesting.net/framework/pytest/pytest-fixtures-nuts-bolts" rel="nofollow">pytest style fixtures</a></li> <li><a href="http://pythontesting.net/framework/pytest/pytest-fixtures-nuts-bolts/#params" rel="nofollow">pytest parameterized fixtures</a></li> </ul><p><a rel="payment" href="https://www.patreon.com/testpodcast">Support Test &amp; Code - Software Testing, Development, Python</a></p>