0
我使用JUnit 3中,当我写了这个代码,我得到这个错误JUnit测试错误没有测试发现
AssertionFailedError异常:没有检测发现
import junit.framework.TestCase;
import junit.runner.*;
public class Teststd extends TestCase {
Student s;
public void setUp() {
s = new Student("ASJFA");
}
public void TestEmail() {
try {
s.setEmail("KUKU");
assertTrue(false);
} catch (EmailIsInvalid ex) {
assertTrue(true);
System.out.println("Exception caught. Email is invalid");
}
}
public void tearDown() {
}
}
你不需要注释吗?例如'@ Test' – Gosu
@Gosu:'@ Test'注释是针对JUnit 4而不是JUnit 3.对于JUnit 3,测试方法的名称应该以'test'(小型大写)开头。 – avandeursen
@avandeursen我明白了!感谢您指出:) – Gosu