Question: Given class Student, create a JUnit class, labeled TestStudent, to test the Student class. Class Student has three constructor, and therefore I want you to
Given class Student, create a JUnit class, labeled TestStudent, to test the Student class. Class Student has three constructor, and therefore I want you to have 3 tests, one for each constructor.
public Student() , test that firstName & lastName are null
public Student(String fName, String lName ), test that firstName equals fName and lastName equals lName
public Student(String fName, String lName, double gpax ), test that firstName equals fName and lastName equals lName and gpa == gpax.
public class Student { private String firstName; private String lastName; private double gpa; public Student() { firstName = null; lastName = null; } public Student(String fName, String lName ) { firstName = fName; lastName = lName; } public Student(String fName, String lName, double gpa ) { firstName = fName; lastName = lName; this.gpa = gpa; } public void setFirstName(String newName) {firstName = newName; } public void setLastName(String newName){ lastName = newName;} public void setGpa(double newGpa){ gpa = newGpa;} public String getFirstName() { return firstName; } public String getLastName() { return lastName;} public double getGpa() { return gpa;} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
