How to assert greater than using JUnit Assert?

前端 未结 8 831
你的背包
你的背包 2020-12-25 09:04

I have these values coming from a test

previousTokenValues[1] = \"1378994409108\"
currentTokenValues[1] = \"1378994416509\"

and I try

8条回答
  •  生来不讨喜
    2020-12-25 09:39

    When using JUnit asserts, I always make the message nice and clear. It saves huge amounts of time debugging. Doing it this way avoids having to add a added dependency on hamcrest Matchers.

    previousTokenValues[1] = "1378994409108";
    currentTokenValues[1] = "1378994416509";
    
    Long prev = Long.parseLong(previousTokenValues[1]);
    Long curr = Long.parseLong(currentTokenValues[1]);
    assertTrue("Previous (" + prev + ") should be greater than current (" + curr + ")", prev > curr);
    

提交回复
热议问题