February 2022
Intermediate to advanced
274 pages
6h 28m
English
Sending some values through a function and checking the output to make sure it’s correct is a common pattern in software testing. However, calling a function once with one set of values and one check for correctness isn’t enough to fully test most functions. Parametrized testing is a way to send multiple sets of data through the same test and have pytest report if any of the sets failed.
To help understand the problem parametrized testing is trying to solve, let’s write some tests for the finish() API method:
| | def finish(self, card_id: int): |
| | """Set a card state to 'done'.""" |
| | self.update_card(card_id, Card(state="done")) |
The states used in the application are “todo,” “in prog,” ...
Read now
Unlock full access