写了个很简单的测试用例,可是老是显示测试失败。netbean6.7.1
被测试类:
package javaapplication4;
public class NewClass {
public int add(int a,int b){
return a+b;
}
}
测试类
/*
- To change this template, choose Tools | Templates
- and open the template in the editor. */
package javaapplication4;
import junit.framework.TestCase;
public class NewClassTest extends TestCase {
public NewClassTest(String testName) {
super(testName);
}
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
/**
* Test of add method, of class NewClass.
*/
public void testAdd() {
System.out.println("add");
int a = 3;
int b = 4;
NewClass instance = new NewClass();
int expResult = 7;
int result = instance.add(a, b);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
}
测试类基本都是netbean自己写的,现在测试老是显示失败
Tests run: 1, Failures: 1, Errors: 0, Time elapsed: 0.016 sec
------------- Standard Output ---------------
add
Testcase: testAdd(javaapplication4.NewClassTest): FAILED
The test case is a prototype.
junit.framework.AssertionFailedError: The test case is a prototype.
at javaapplication4.NewClassTest.testAdd(NewClassTest.java:42)
Test javaapplication4.NewClassTest FAILED