Skip to content

Printing of useful information when unit test fail #320

Closed Answered by mkorbel1
quekyj asked this question in Q&A
Discussion options

You must be logged in to vote

You can use the reason named argument in expect to print a more helpful message.

For example:

          final expected = faTruthTable(i, j, k).sum;
          final actual = sum.value.toInt();
          expect(sum.value.toInt(), expected,
              reason: 'For inputs a=$i, b=$j, cIn=$k,'
                  ' expected sum=$expected but found $actual');

Now when the test fails it prints

Expected: <0>
  Actual: <1>
For inputs a=1, b=1, cIn=1, expected sum=0 but found 1

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by quekyj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants