【发布时间】:2020-09-19 07:01:08
【问题描述】:
我目前正在尝试创建一个调用另一个类的 JUnit 测试。我已经以我知道的每一种方式工作,但我似乎无法做到正确。 GetHistory 测试是让我头疼的一个测试。任何帮助或提示都会很棒!
package medical.com.medicalApplication.model;
/**
*
*
* This class represents a medical record model in the system
*
*/
public class MedicalRecord {
private Patient patient;
private PatientHistory history;
public MedicalRecord(Patient patient) {
super();
this.patient = patient;
this.history = new PatientHistory();
}
public Patient getPatient() {
return patient;
}
public PatientHistory getHistory() {
return history;
}
}
这是我当前的代码:
package medical.com.medicalApplication.model;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import medical.com.medicalApplication.model.PatientHistory;
public class MedicalRecordTest {
@Test
public void testGetPatient() {
String patient = "Perez";
Patient test = new Patient(patient, patient);
assertTrue(test.getName().equals(patient));
}
@Test
public void testGetHistory() {
String history = "Diabetic";
PatientHistory test = new PatientHistory();
assertTrue(test.getHistory.equals("Diabetic"));
}
}
【问题讨论】:
-
欢迎来到 StackOverflow。请不要忘记提及您遇到的确切问题(例如编译错误、断言失败等)。