Test & Code cover image

Test & Code

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

Jan 31, 2016
20:25

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-Teardown
    • Setup-Excercise-Verify-Teardown.
    • Arrange-Act-Assert
    • Preconditions-Trigger-Postconditions.
  • Benefits
    • Communicate the purpose of your test more clearly
    • Focus your thinking while writing the test
    • Make test writing faster
    • Make it easier to re-use parts of your test
    • Highlight the assumptions you are making about the test preconditions
    • Highlight what outcomes you are expecting and testing against.

Links discussed in the show:

★ Support this podcast on Patreon ★

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode