Test & Code

65: one assert per test


Listen Later

Is it ok to have more than one assert statement in a test?

I've seen articles that say no, you should never have more than one assert.
I've also seen some test code made almost unreadable due to trying to avoid more than one assert per test.

Where did this recommendation even come from? What are the reasons?

What are the downsides to both perspectives?

That's what we're going to talk about today.

Links:

  • Twitter survey about multiple asserts/checks — Are multiple asserts/checks ok in an automated test?
  • Multiple Asserts Are OK - Bill Wake
  • pytest-check: A pytest plugin that allows multiple failures per test.
...more
View all episodesView all episodes
Download on the App Store

Test & CodeBy Brian Okken

  • 4.7
  • 4.7
  • 4.7
  • 4.7
  • 4.7

4.7

70 ratings


More shows like Test & Code

View all
Radiolab by WNYC Studios

Radiolab

44,034 Listeners

Software Engineering Daily by Software Engineering Daily

Software Engineering Daily

624 Listeners

Heavy Networking by Packet Pushers

Heavy Networking

326 Listeners

Talk Python To Me by Michael Kennedy

Talk Python To Me

581 Listeners

Python Bytes by Michael Kennedy and Brian Okken

Python Bytes

213 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

8,109 Listeners

The Real Python Podcast by Real Python

The Real Python Podcast

140 Listeners

Unexplainable by Vox

Unexplainable

2,323 Listeners

Network Automation Nerds by Packet Pushers

Network Automation Nerds

5 Listeners