Eclipse: Junit 我在下面的 junit 选项卡中看到这个错误
Eclipse: Junit I am seeing this error in junit tab below
下面是我的简单代码
package M06;
public class ExerciseE03 {
public double calcTotal (double total, boolean existingMember, boolean validDiscount, boolean validCoupon) {
double discount=0.0;
if (existingMember && validDiscount || validCoupon) {
if (total > 1_000.0)
discount = 0.15;
else
if (total >= 750)
discount = 0.1;
else
if (total > 500)
discount = 0.05;
else
discount = 0.025;
}
return (total * (1-discount) * 1.0825);
}
}
这是j单元文件
package M06;
import static org.junit.Assert.*;
import static junitparams.JUnitParamsRunner.$;
import org.junit.Before;
import org.junit.Test;
import junitparams.FileParameters;
public class ExerciseE03Test {
private ExerciseE03 object;
@Before
public void setUp() throws Exception {
object = new ExerciseE03();
}
@Test
@FileParameters("src/M06/E03TestCaseTable.csv")
public void test(int testcaseNumber, boolean member, boolean disc, boolean coupon, double total, double discount, double output) {
//ExerciseE03 object = new ExerciseE03();
//assertEquals(1380.1875, object.calcTotal(1500, true, true, true),0.001);
object.calcTotal( total, member, disc, coupon);
assertEquals(output,object.calcTotal(total, member, disc, coupon),0.01);
}
}
我还在下面提供了我的 junit 屏幕截图。由于我是 juint 的新手,我不知道针对此类错误需要采取哪些步骤
以上是我在下面的 junit 选项卡中看到的错误。
在测试 class 的顶部使用 @RunWith(JUnitParamsRunner.class) 注释,ExerciseE03Test。
@RunWith(JUnitParamsRunner.class)
public class ExerciseE03Test {
检查此 post 以了解更多信息。
下面是我的简单代码
package M06;
public class ExerciseE03 {
public double calcTotal (double total, boolean existingMember, boolean validDiscount, boolean validCoupon) {
double discount=0.0;
if (existingMember && validDiscount || validCoupon) {
if (total > 1_000.0)
discount = 0.15;
else
if (total >= 750)
discount = 0.1;
else
if (total > 500)
discount = 0.05;
else
discount = 0.025;
}
return (total * (1-discount) * 1.0825);
}
}
这是j单元文件
package M06;
import static org.junit.Assert.*;
import static junitparams.JUnitParamsRunner.$;
import org.junit.Before;
import org.junit.Test;
import junitparams.FileParameters;
public class ExerciseE03Test {
private ExerciseE03 object;
@Before
public void setUp() throws Exception {
object = new ExerciseE03();
}
@Test
@FileParameters("src/M06/E03TestCaseTable.csv")
public void test(int testcaseNumber, boolean member, boolean disc, boolean coupon, double total, double discount, double output) {
//ExerciseE03 object = new ExerciseE03();
//assertEquals(1380.1875, object.calcTotal(1500, true, true, true),0.001);
object.calcTotal( total, member, disc, coupon);
assertEquals(output,object.calcTotal(total, member, disc, coupon),0.01);
}
}
我还在下面提供了我的 junit 屏幕截图。由于我是 juint 的新手,我不知道针对此类错误需要采取哪些步骤
以上是我在下面的 junit 选项卡中看到的错误。
在测试 class 的顶部使用 @RunWith(JUnitParamsRunner.class) 注释,ExerciseE03Test。
@RunWith(JUnitParamsRunner.class)
public class ExerciseE03Test {
检查此 post 以了解更多信息。