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.
Sponsored By:
Support Test & Code - Software Testing, Development, Python
Links:
<p>Is it ok to have more than one assert statement in a test? <br> I've seen articles that say no, you should never have more than one assert.<br> I've also seen some test code made almost unreadable due to trying to avoid more than one assert per test.</p> <p>Where did this recommendation even come from? What are the reasons? <br> What are the downsides to both perspectives?</p> <p>That's what we're going to talk about today.</p><p>Sponsored By:</p><ul><li><a rel="nofollow" href="http://testandcode.com/pycharm">PyCharm Professional</a>: <a rel="nofollow" href="http://testandcode.com/pycharm">Try PyCharm Pro for an extended 4 month trial before deciding which version you need. If you value your time, you owe it to yourself to try PyCharm.</a> Promo Code: TESTNCODE2019</li></ul><p><a rel="payment" href="https://www.patreon.com/testpodcast">Support Test & Code - Software Testing, Development, Python</a></p><p>Links:</p><ul><li><a title="Twitter survey about multiple asserts/checks" rel="nofollow" href="https://twitter.com/brianokken/status/1095222007203950592">Twitter survey about multiple asserts/checks</a> — Are multiple asserts/checks ok in an automated test?</li><li><a title="Multiple Asserts Are OK - Bill Wake" rel="nofollow" href="https://www.industriallogic.com/blog/multiple-asserts-are-ok/">Multiple Asserts Are OK - Bill Wake</a></li><li><a title="pytest-check: A pytest plugin that allows multiple failures per test." rel="nofollow" href="https://github.com/okken/pytest-check">pytest-check: A pytest plugin that allows multiple failures per test.</a></li></ul>
from Planet Python
via
read more
No comments:
Post a Comment