I've written 48 test methods to test my course assignment. None of them is an exceptional test but they are working correctly. Finally, I tried to test my own exceptions, jUnit 5 doesn't see it. There are some examples of my code design and exception test.
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import junit.framework.TestCase;
public class Final_Tests extends TestCase {
@Test
public static void testD4_setChair() {
Department testD = new Department("CSE 101","CSE 101!");
Teacher testT = new Teacher("Ali","Veli.com",testD,"CV");
testD.setChair(testT);
assertEquals(testT,testD.getChair());
}
There is no problem with testing non-exception methods. The problem is here.
@Test
public static void DepartmentMismatchException_Test() {
Department testD = new Department("CSE 101","CSE 101!");
Teacher testT = new Teacher("Mehmet", "mehmet.com", testD, "CV Mehmet");
Course testC1 = new Course(testD,101,"Test Course 1","Test Course 1 Desc.",testT,6);
String expMsg = "DepartmentMismatchException: Teacher in " + testT.getDepartment().getCode()+ ", Course in " +testC1.getDepartment().getCode();
DepartmentMismatchException dme = new DepartmentMismatchException(testT.getDepartment(), testC1.getDepartment());
assertEquals(expMsg, dme.toString());
}
Is a problem with code design like usage of scopes, static or other modifiers, or about my exception test codes?
Aucun commentaire:
Enregistrer un commentaire