Junit: less-than assertion?

junit, unit-testing

Solution

Have you tried JUnit + Hamcrest? See this blog post for some examples—it looks almost exactly like what you posted:

JUnit 4 Showcase – assertThat and Hamcrest Matchers

Alternatively, there's also ComparableAssert from the JUnit-addons project.

Problem

Is there anything like `assertThat(a, lessThan(b));` ? I'm currently using Junit 4.8.1 and I haven't been able to find lessThan. Instead I have to do `assertTrue(a < b)`, but this has a drawback that it doesn't print two numbers in test log.

Original source