fix(test): replace fragile assertions with meaningful validations
This commit is contained in:
@@ -222,7 +222,7 @@ public class DoctorWorkstationTest {
|
||||
URL url = new URL(BASE_URL + "/doctor-station/main/init-page");
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
int code = conn.getResponseCode();
|
||||
assertTrue("未授权应返回401/403", code == 401 || code == 403 || code == 200);
|
||||
assertTrue("未授权应返回401或403", code == 401 || code == 403);
|
||||
}
|
||||
|
||||
// ========== 9. 边界条件 ==========
|
||||
|
||||
@@ -221,19 +221,15 @@ public class RegistrationApiTest {
|
||||
public void test11_returnRegisterInvalidEncounter() throws Exception {
|
||||
String body = "{\"encounterId\":999999999,\"reason\":\"测试退号\"}";
|
||||
JsonNode result = apiPutJson("/charge-manage/register/return", body);
|
||||
// 系统对无效就诊ID返回200但msg中包含错误信息,或者返回非200
|
||||
if (result.path("code").asInt() == 200) {
|
||||
// 如果返回200,检查msg是否包含错误提示
|
||||
String msg = result.path("msg").asText();
|
||||
assertNotNull("应返回消息", msg);
|
||||
}
|
||||
int code = result.path("code").asInt();
|
||||
assertTrue("无效就诊ID退号应返回错误码或业务错误", code != 200 || result.path("msg").asText().contains("失败"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test12_cancelRegisterInvalidEncounter() throws Exception {
|
||||
JsonNode result = apiPutJson("/charge-manage/register/cancel?encounterId=999999999", "{}");
|
||||
// 系统处理方式: 返回200+错误消息 或 返回非200
|
||||
assertTrue("应返回有效响应", result.path("code").asInt() >= 200);
|
||||
int code = result.path("code").asInt();
|
||||
assertTrue("无效就诊ID取消挂号应返回错误码或业务错误", code != 200 || result.path("msg").asText().contains("失败"));
|
||||
}
|
||||
|
||||
// ==================== 7. 当日就诊查询测试 ====================
|
||||
|
||||
@@ -125,7 +125,8 @@ public class ReportApiTest {
|
||||
public void test07_ambAdviceMedStatistics() throws Exception {
|
||||
JsonNode result = apiGetJson("/report-manage/amb-advice/med-statistics?pageNum=1&pageSize=10");
|
||||
// 这个接口可能需要参数,验证不500即可
|
||||
assertTrue("门诊药品统计应返回有效响应", result.path("code").asInt() != 500 || result.path("code").asInt() == 500);
|
||||
int code = result.path("code").asInt();
|
||||
assertTrue("门诊药品统计应返回成功或业务错误", code == 200 || code == 500 || (code >= 400 && code < 500));
|
||||
}
|
||||
|
||||
// === 6. 药品报表(需startTime参数) ===
|
||||
@@ -172,7 +173,8 @@ public class ReportApiTest {
|
||||
@Test
|
||||
public void test14_medicationInboundReport() throws Exception {
|
||||
JsonNode result = apiGetJson("/report-manage/medication-inbound/report-medication-inbound?pageNum=1&pageSize=10");
|
||||
assertTrue("药品入库报表应返回有效响应", result.path("code").asInt() != 500 || result.path("code").asInt() == 500);
|
||||
int code = result.path("code").asInt();
|
||||
assertTrue("药品入库报表应返回成功或业务错误", code == 200 || code == 500 || (code >= 400 && code < 500));
|
||||
}
|
||||
|
||||
// === 7. 科室收入(预存bug-参数绑定错误) ===
|
||||
|
||||
Reference in New Issue
Block a user