第一步:封装被测方法or接口的参数
class Parameters { private String tenantId = "MYNTW3PH"; private String sceneId = "PH_DEFAULT"; public void setTenantId(String tenantId1){ this.tenantId = tenantId1; } public String getTenantId(){ return tenantId; } public void setSceneId(String sceneId1){ this.sceneId = sceneId1; } public String getSceneId(){ return sceneId; } }
第二步:对被测方法or接口制模(被测方法:getCrowdListByScene)
public void getCrowdListBySceneTestBase(Parameters parameters1){ /**数据准备*/ CrowdListRequest crowdListRequest = new CrowdListRequest(); crowdListRequest.setTenantId(parameters1.getTenantId());//只看这两个即可,其他逻辑可以忽略(这是博主的业务场景) crowdListRequest.setSceneId(parameters1.getSceneId());//只看这两个即可,其他逻辑可以忽略(这是博主的业务场景) crowdListRequest.setPageNum(1); crowdListRequest.setPageSize(100); /**调用*/ GenericResult<PageVO<List<CrowdInfoVO>>> genericResult = crowdFacade.getCrowdListByScene(crowdListRequest); /**验证*/ for (int i = 0; i < genericResult.getValue().getValues().size(); i++) { System.out.println(crowdListRequest.getTenantId() + "人群信息【" + i + "】:" + genericResult.getValue().getValues().get(i)); } Assert.assertTrue(genericResult.isSuccess()); }
第三步:调用模板
/**正常场景*/ public void case1_1getCrowdListBySceneTest(){ getCrowdListBySceneTestBase(parameters); } /**异常场景:tenantId空*/ public void case1_3getCrowdListBySceneTest(){ parameters.setTenantId(null); getCrowdListBySceneTestBase(parameters); }
原文地址:https://www.cnblogs.com/danhuai/p/10704712.html
时间: 2024-11-07 10:17:54