Alex Rivera | Logout

Assertion messages: assume failure, or assume success

Asked 2008-12-20T08:40:22.593
10

When testing in any language, how does everybody phrase their assertion messages?

I see three obvious ways:

# assume failure
assert (4-2) == 2, "Subtracting 2 from 4 doesn't equal 2"

# describe success
assert (4-2) == 2, "Subtracting 2 from 4 should equal 2"

# be vauge with failure
assert (4-2) == 2, "Subtracting 2 from 4 is broken"

This is obviously a simple example, but you get the idea. What is the standard practice? What do you do? Why?

Edit
Report

1 Answer

1

I use the assertion message to document what the assertion is testing, or what the expected value is about.

Sometimes, when a test fails, I do not need to look at the failing test : just from assertion message and the change(s) I just made, I know how to fix it.

answered 2008-12-20T12:39:23.173

Your Answer