我不知道我的测试/项目出了什么问题。我没有编译错误,但是当我对其进行测试时,它只是红色的条,并且不会告诉我有什么问题。有什么建议么?我的代码和问题如下。预先感谢
如果在装有一本书的购物篮中调用checkout的calculatePrice方法,则应返回该一本书的价格。
@Test
public void test_CalculatePrice_ReturnSumOfThePriceOfTwoBooks_BasketMustHaveTwoBooks(){
//Arrange
Basket basket1 = new Basket();
Book book1 = new Book();
Checkout checkout = new Checkout();
basket1.addBook(book1);
basket1.addBook(book1);
double delta = 0.0;
double expectedPrice = checkout.calculatePrice();
//Act
double actualPrice = checkout.calculatePrice();
//Assert
assertEquals(expectedPrice,actualPrice,delta);
结帐课程
public class Checkout {
public double calculatePrice(Book book1) {
return calculatePrice();
}
答案 0 :(得分:0)
您的calculatePrice()方法在做什么? 在您的Checkout类中,您的方法
public double calculatePrice(Book book1) {
return calculatePrice();
}
我想您的意思是甚至没有使用book1参数来计算价格
public double calculatePrice(Book book1) {
return book1.calculatePrice();
}