2011-09-15 27 views
1

我有一個字符串,我想檢查這個字符串> 0 使用斷言Junit的:我怎樣使用斷言來檢查字符串> 0

嘗試: 使用assertFalse我不能設置2串:我的價值和「0」。

有沒有另一種說法:assertThat「myString」>「0」?

我的目的:

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

感謝

+0

您要檢查如果字符串> 0,或字符串的長度* *> 0?你可以添加你的測試目前的樣子嗎? – matt

+0

我更新了問題,是的,我想檢查字符串是否> 0 – lola

回答

4

你真正想要做的比較的數量,以保證安全。所以,你要像

assertTrue(Integer.parseInt(myTable.getValue()) > 0) 
相關問題