我在想为什么assertEquals(double, double)
已经被弃用。
我使用了import static org.junit.Assert.assertEquals;
以及JUnit 4.11。
以下是我的代码:
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class AccountTest {
@Test
public void test() {
Account checking = new Account(Account.CHECKING);
checking.deposit(1000.0);
checking.withdraw(100.0);
assertEquals(900.0, checking.getBalance());
}
}
checking.getBalance()
返回一个 double 类型的值。
可能出了什么问题?
Assert.assertEquals(2.49, 2.49, 0.1);
的方式。 - Arjun Kalidasdouble
来表示货币金额而不是某个第三方库类或专门用于货币的自定义类而使测试失败。 - Alonso del Arte