I used JUnit 3 and when I wrote this code I got this error
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() {
}
}
@Test
@Test
annotations are for JUnit 4, not JUnit 3. For JUnit 3 names of test methods should start withtest
(small caps).@Test(expected=EmailIsInvalid.class)
, allowing you to get rid of the try-catch.