我有一個不斷失敗下面的測試方法:的JUnit的assertEquals失敗
/**
* 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.");
}
的方法工作得很好,當我調試測試,結果和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)
任何人都知道爲什麼會發生這種情況,以及如何解決它?
我缺少的東西?我不明白:你在調用'失敗(...)'並詢問爲什麼你會得到一個失敗的測試? – Thomas