Search code examples
junit4

Junit : how could I use assertion to check String >0


I have a String and I would like to check that this string is > 0 using assert

trying : using assertFalse I can't set 2 strings : my value and "0" .

Is there another way to say : assertThat "myString"> "0" ?

my purpose :

myTable.getValue =>this return a string : "20"
I would like to check that this string is > or different from "0" 

thanks


Solution

  • You really want to do the comparison as a number, for safety. So you want something like

    assertTrue(Integer.parseInt(myTable.getValue()) > 0)