Junit中對double型別進行assert對比

2021-08-18 01:17:57 字數 293 閱讀 8984

在junit測試中使用到了將double型別的資料進行比較,但是出現以下錯誤:

報錯資訊:

the method assertequals(double, double) from the type assert is deprecated

junit中沒有assertequals(double,double)的方法。因為double值是允許誤差的。

所以要實現double的斷言要用assertequals(double,double,double)這個方法。

其中第三個引數是允許誤差 。

Junit中對兩double型別值的比較

使用junit 4 測試正確性時出現以下錯誤 the method assertequals double,double from the type assert is deprecated 經查閱相關資料發現junit中沒有assertequals double,double 的方法,因為doub...

Junit中double型別的比較

在寫junit單元測試的時候發現直接用assertequals double,double 比較時會發生錯誤。報錯資訊 the method assertequals double,double from the type assert is deprecated junit中沒有assertequ...

Java中對double型別保留兩位小數的方法

整理了網上一些方法,方便以後查閱。1.使用bigdecimal類 bigdecimal b1 new bigdecimal width bigdecimal b2 new bigdecimal height bigdecimal b3 b1.multiply b2 return b3.setscal...