JUnit assertEquals失败

nec*_*666 1 java junit

我有以下测试方法,它会一直失败:

/**
 * Test of averageResult method, of class MonthlyPayroll.
 */
public void testAverageResult() {
    System.out.println("averageResult");
    double[] MonthlySales = {4, 5, 6, 7, 8, 9};
    int howMany = 6;
    double expResult = 6.5;
    double epsilon = 1;
    double result = MonthlyPayroll.averageResult(MonthlySales, howMany);
    assertEquals(expResult, result, epsilon);
    // TODO review the generated test code and remove the default call to fail.
    fail("The test case is a prototype.");
}
Run Code Online (Sandbox Code Playgroud)

该方法工作正常,当我调试测试,结果和expResult相等,但我收到以下失败消息:

compile-test-single:
Testsuite: pkgbmc.MonthlyPayrollTest
averageResult
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.109 sec

------------- Standard Output ---------------
averageResult
------------- ---------------- ---------------
Testcase: testAverageResult(pkgbmc.MonthlyPayrollTest): FAILED
The test case is a prototype.
junit.framework.AssertionFailedError: The test case is a prototype.
at pkgbmc.MonthlyPayrollTest.testAverageResult(MonthlyPayrollTest.java:61)
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么会这样,以及如何解决它?

Jen*_*der 10

呼吁失败

fail("The test case is a prototype.");
Run Code Online (Sandbox Code Playgroud)

使测试失败.

请注意,在我知道的任何IDE中,您可以(双)单击该行

at pkgbmc.MonthlyPayrollTest.testAverageResult(MonthlyPayrollTest.java:61)
Run Code Online (Sandbox Code Playgroud)

让你准确到达有问题的线,这不是你的 assertEquals

  • 代码中甚至有一个很大的*TODO*:"删除默认调用失败";) (4认同)