Hi i need help implementing the proper code for a JUnit test within my code for
ID: 3905105 • Letter: H
Question
Hi i need help implementing the proper code for a JUnit test within my code for eclipse oxygen:
package medical.com.medicalApplication.model;
import static org.junit.Assert.*;
import org.junit.Test;
public class Employee {
private String name;
private String id;
private String password;
public Employee(String name, String id) {
super();
this.name = name;
this.id = id;
this.password = "Open";
}
public String getName() {
return name;
}
public String getId() {
return id;
}
public String getPassword() {
return password;
}
}
Explanation / Answer
import static org.junit.Assert.*; import org.junit.Test; public class EmployeeTest { Employee employee = new Employee("Employee Name","Employee ID"); @Test public void TestGetName(){ assertEquals(employee.getName(),"Employee Name"); } @Test public void TestGetID(){ assertEquals(employee.getId(),"Employee ID"); } @Test public void TestGetPassword(){ assertEquals(employee.getPassword(),"Open"); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.