From fc6f04db7b8bd081c94e91ce4f4f5f6860c409d3 Mon Sep 17 00:00:00 2001 From: fdai7921 Date: Wed, 7 Feb 2024 15:54:38 +0100 Subject: [PATCH] refactoring: extract sampleCourse in AdministrationTest file --- src/test/java/org/example/AdministrationTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index b223cf4..ef6ebcb 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -6,6 +6,8 @@ import static org.junit.jupiter.api.Assertions.*; class AdministrationTest { + private static final Course sampleCourse = new Course("Math", "M101", 4); + // Test the findProfessorById Method @Test void findProfessorById() { @@ -79,7 +81,7 @@ class AdministrationTest { @Test void addCourse() { Administration admin = new Administration(); - Course course = new Course("Math", "M101", 4); + Course course = sampleCourse; admin.addCourse(course); assertEquals(course, admin.findCourseByID("M101")); } @@ -92,7 +94,7 @@ class AdministrationTest { public void testDeleteCourse() { Administration administration = new Administration(); // Adding a course - Course course = new Course("Math", "M101", 4); + Course course = sampleCourse; administration.addCourse(course); // Deleting the course @@ -110,7 +112,7 @@ class AdministrationTest { public void testFindCourseByID() { Administration administration = new Administration(); // Adding a course - Course course = new Course("Math", "M101", 4); + Course course = sampleCourse; administration.addCourse(course); // Finding the added course