Why most (all?) unit test frameworks have large APIs with separate functions for specifying different types of boolean conditions (eg. assertEquals, assertNotEqual, etc) instead of using single assert function (or language construct) with desired boolean expression?
Why most (all?) unit test frameworks have large APIs with separate functions for specifying
Share
A simple
assertwill only throwAssertionErrorstating that the asserted conditation evaluated to false:(not to mention
assert string1 == string2is incorrect due to reference comparison)By passing both
aandbthe library can include them in the error message. Here: FEST assertions:Note that some languages are more powerful:
In Groovy (example from: Groovy 1.7 Power Assert):
yields:
In Scala (ScalaTest) there is a special
===operator:yields
1 did not equal 2.