I’m looking for asserts in the style of Google’s testing framework, where something like ASSERT_LT(a, b) will check that $a is less than $b, and if not, will print the values of $a and $b in the error message. The asserts I’ve found so far just stop execution without printing anything useful by default. Any pointers?
Bonus: I like to write assertion-heavy code (not just in the tests), so it would be nice if the assertions are quick to evaluate.
Context: I came across this when writing unittests using this code as a template.
Specs2 defines a number of matchers such as
must be_<=. At first I thought these needed to integrated into a specification, but at the bottom of the matchers page it says that they are modular functionality that “you should be able to reuse in your own testframework“. As an example, “You can reuse [traits such as]
org.specs2.matcher.MustMatchersto write anything like1 must be_==(1)andget a Result back“.
ScalaTest has its own matchers, as well. For example,
one must be < (7).