I have these values coming from a test
previousTokenValues = "1378994409108" currentTokenValues = "1378994416509"
and I try
// current timestamp is greater assertTrue(Long.parseLong(previousTokenValues) > Long.parseLong(currentTokenValues));
I get the
detailMessage on debugging is
How can I assert greater than conditions in using
Just how you’ve done it.
assertTrue(boolean) also has an overload
assertTrue(String, boolean) where the
String is the message in case of failure; you can use that if you want to print that such-and-such wasn’t greater than so-and-so.
You could also add
hamcrest-all as a dependency to use matchers. See https://code.google.com/p/hamcrest/wiki/Tutorial:
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; assertThat("timestamp", Long.parseLong(previousTokenValues), greaterThan(Long.parseLong(currentTokenValues)));
That gives an error like:
java.lang.AssertionError: timestamp Expected: a value greater than <456L> but: <123L> was less than <456L>