Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
Your line manager has instructed you to write unit tests to determine the code coverage in the student management application....Question
Your line manager has instructed you to write unit tests to determine the code coverage in the student management application. You are required to create a test package within the application you created in Section A, which will contain the required unit tests.
You are required to write the following unit tests:
TEST NAME: TEST PURPOSE:
TESTSAVESTUDENT(). To supply the student ID, name, age,email,and course to the save the student method.The test will determine whether the correct student will be save to memory.
TEST NAME : Test Purpose:
TestSearchStudent(). To supply the student id to the search student method.The test will determine that the correct student details have been returned.
TEST NAME: TEST PURPOSE:
TestSearchStudent_StudentNotFound(): To supply an incorrect student ID to the search method.The test will determine that no student no student was found
TEST NAME: TEST PURPOSE:
TestDeleteStudent(). To supply the student ID to the delete student method.The test will determine that the student has been successfully deleted.
TEST NAME: TEST PURPOSE:
TestDeleteStudent_StudentNotFound(). TO supply an incorrect student ID to the delete student method .The test will determine that no student could be found to delete.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeValid(). To supply a valid student age to the student age method.The test will determine that the student age is valid.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeInvalid(). To supply an invalid student age to the student age method.The test will determine that the students age is less than 16.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeInvalidCharacter(). To supply an invalid character to the student age method.The test will determine that the student age supplied is not a number.
In java
You are required to write the following unit tests:
TEST NAME: TEST PURPOSE:
TESTSAVESTUDENT(). To supply the student ID, name, age,email,and course to the save the student method.The test will determine whether the correct student will be save to memory.
TEST NAME : Test Purpose:
TestSearchStudent(). To supply the student id to the search student method.The test will determine that the correct student details have been returned.
TEST NAME: TEST PURPOSE:
TestSearchStudent_StudentNotFound(): To supply an incorrect student ID to the search method.The test will determine that no student no student was found
TEST NAME: TEST PURPOSE:
TestDeleteStudent(). To supply the student ID to the delete student method.The test will determine that the student has been successfully deleted.
TEST NAME: TEST PURPOSE:
TestDeleteStudent_StudentNotFound(). TO supply an incorrect student ID to the delete student method .The test will determine that no student could be found to delete.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeValid(). To supply a valid student age to the student age method.The test will determine that the student age is valid.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeInvalid(). To supply an invalid student age to the student age method.The test will determine that the students age is less than 16.
TEST NAME: TEST PURPOSE:
TestStudentAge_StudentAgeInvalidCharacter(). To supply an invalid character to the student age method.The test will determine that the student age supplied is not a number.
In java
Answers
There are no human answers yet.
Answered by
GPT 3.5
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;
public class StudentManagementApplicationTest {
private StudentManagementApplication studentManagementApplication;
@Before
public void setUp() {
studentManagementApplication = new StudentManagementApplication();
}
@Test
public void testSaveStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "[email protected]";
String course = "Computer Science";
studentManagementApplication.saveStudent(studentId, name, age, email, course);
assertNotNull(studentManagementApplication.getStudent(studentId));
}
@Test
public void testSearchStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "[email protected]";
String course = "Computer Science";
studentManagementApplication.saveStudent(studentId, name, age, email, course);
Student student = studentManagementApplication.searchStudent(studentId);
assertEquals(studentId, student.getStudentId());
assertEquals(name, student.getName());
assertEquals(age, student.getAge());
assertEquals(email, student.getEmail());
assertEquals(course, student.getCourse());
}
@Test
public void testSearchStudent_StudentNotFound() {
String studentId = "456";
Student student = studentManagementApplication.searchStudent(studentId);
assertNull(student);
}
@Test
public void testDeleteStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "[email protected]";
String course = "Computer Science";
studentManagementApplication.saveStudent(studentId, name, age, email, course);
boolean result = studentManagementApplication.deleteStudent(studentId);
assertTrue(result);
assertNull(studentManagementApplication.getStudent(studentId));
}
@Test
public void testDeleteStudent_StudentNotFound() {
String studentId = "456";
boolean result = studentManagementApplication.deleteStudent(studentId);
assertFalse(result);
}
@Test
public void testStudentAge_StudentAgeValid() {
int age = 20;
boolean result = studentManagementApplication.isValidAge(age);
assertTrue(result);
}
@Test
public void testStudentAge_StudentAgeInvalid() {
int age = 15;
boolean result = studentManagementApplication.isValidAge(age);
assertFalse(result);
}
@Test
public void testStudentAge_StudentAgeInvalidCharacter() {
String age = "twenty";
boolean result = studentManagementApplication.isValidAge(age);
assertFalse(result);
}
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;
public class StudentManagementApplicationTest {
private StudentManagementApplication studentManagementApplication;
@Before
public void setUp() {
studentManagementApplication = new StudentManagementApplication();
}
@Test
public void testSaveStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "[email protected]";
String course = "Computer Science";
studentManagementApplication.saveStudent(studentId, name, age, email, course);
assertNotNull(studentManagementApplication.getStudent(studentId));
}
@Test
public void testSearchStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "[email protected]";
String course = "Computer Science";
studentManagementApplication.saveStudent(studentId, name, age, email, course);
Student student = studentManagementApplication.searchStudent(studentId);
assertEquals(studentId, student.getStudentId());
assertEquals(name, student.getName());
assertEquals(age, student.getAge());
assertEquals(email, student.getEmail());
assertEquals(course, student.getCourse());
}
@Test
public void testSearchStudent_StudentNotFound() {
String studentId = "456";
Student student = studentManagementApplication.searchStudent(studentId);
assertNull(student);
}
@Test
public void testDeleteStudent() {
String studentId = "123";
String name = "John Doe";
int age = 20;
String email = "[email protected]";
String course = "Computer Science";
studentManagementApplication.saveStudent(studentId, name, age, email, course);
boolean result = studentManagementApplication.deleteStudent(studentId);
assertTrue(result);
assertNull(studentManagementApplication.getStudent(studentId));
}
@Test
public void testDeleteStudent_StudentNotFound() {
String studentId = "456";
boolean result = studentManagementApplication.deleteStudent(studentId);
assertFalse(result);
}
@Test
public void testStudentAge_StudentAgeValid() {
int age = 20;
boolean result = studentManagementApplication.isValidAge(age);
assertTrue(result);
}
@Test
public void testStudentAge_StudentAgeInvalid() {
int age = 15;
boolean result = studentManagementApplication.isValidAge(age);
assertFalse(result);
}
@Test
public void testStudentAge_StudentAgeInvalidCharacter() {
String age = "twenty";
boolean result = studentManagementApplication.isValidAge(age);
assertFalse(result);
}
}
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.