java JUnit测试错误未找到测试
我使用JUnit3,当我编写这段代码时,我遇到了这个错误
AssertionFailedError : No test Found
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() {
}
}
# 1 楼答案
您的测试方法应该以小写的
t
开头。它应该是public void testEmail()
。然后它将被JUnit拾取