Test Smell: Multiple Assertions
Learn the importance of writing one assert per test.
We'll cover the following
We’ll sometimes find reasons to assert multiple postconditions in a single test. However, more often the multiple assertions indicate that we have two test cases.
Split me
Our longer test screams, “Split me!” The first case represents successfully finding a search result in the input, and the second case represents finding no match. Split the test into two, providing each with a name that concisely states the expected behavior given the context for the test:
Get hands-on with 1400+ tech skills courses.