[英]Using assertEquals in Junit test. How can I correct it?
public class MyTestCase {
private MaxHeap testHeap;
MaxHeap Student = new MaxHeap();
@Before
public void setUp() throws Exception
{
testHeap = new MaxHeap(10);
testHeap.insert(new Student("Susan", 60, 3.5));
testHeap.insert(new Student("Ben", 70, 3.4));
testHeap.insert(new Student("Reed", 120, 4.0));
testHeap.insert(new Student("Troy", 90, 1.1));
testHeap.insert(new Student("Johnny", 50, 2.3));
}
@Test
public void testInsert() {
Student.name("Ciroc");
Student.setGPA(3.3);
Student.setUnits(75);
double testCase = MaxHeap.insert(students);
assertEquals(3.3, testHeap.extractMax().gpa(), 0.0);
}
}
I like to use JUnit test, to test the insert method in the heap, if the student with higher GPA will replace the student with the lower GPA.我喜欢用JUnit测试,测试堆中的insert方法,如果GPA高的学生会替换GPA低的学生。 This is the first time I use JUnit.这是我第一次使用 JUnit。 I'm not sure if it's right, please correct me.不知道对不对,请指正。 Thank you.谢谢你。
Here is the link for MaxHeap and Student class Click Here这是 MaxHeap 和 Student 类的链接单击此处
Yes.是的。 It's correct.这是正确的。
@param expected - expected value
@param actual - the value to check against <code>expected</code>
@param delta - the maximum delta between <code>expected</code> and
static public void assertEquals(double expected, double actual, double delta) {...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.