Junit中對兩double類型值的比較

使用JUnit 4 測試正確性時出現以下錯誤
在這裏插入圖片描述
The method assertEquals(double,double) from the type Assert is deprecated

經查閱相關資料發現JUnit中沒有assertEquals(double,double) 的方法,因爲double值比較相等時存在誤差
需要用assertEquals(double,double,double) 方法進行比較
其中第三個參數爲誤差

添加誤差後測試通過
在這裏插入圖片描述
參考資料:
https://blog.csdn.net/hadelu/article/details/79784

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章