In previous posts we discussed the problem with multiple asserts in the unit test. One of the reasons to create test with only single assert was “Unit Test Misinformation”.

One of the readers of my blog remainded me in the comments that there are frameworks that can help in a situation like this. One example of such a framework is One Assert Per Test - OAPT

What does it do.

Oapt saves you this trouble by running your unit tests several times, each time using one assert and ignoring the rest.

Quite cool idea, that can save a lot of trouble.

Still I think that unit test should only contain one assert whenever possible. When it’s not, frameworks like this are quite helpfull :)

Share