我用forEach
循环编写了一个Java类,该类迭代对象列表。请参见下面的代码。
public List<Customer> getBranchDealersForDealer(String orgId, String regionId, String districtId, String dealerCode) {
List<Customer> branchDealers = customerRepository.branchDealersForDealer(orgId, regionId, districtId, dealerCode);
for(Customer c : branchDealers){
c.setOrgId(orgId);
c.setRegionId(regionId);
c.setDistrictId(districtId);
}
List<WarrantyDealerView> warrantyBranchDealers =
warrantyDealerService.getDealersForCodesIn(toDealerIds(branchDealers));
return applyUpdatesFromWarranty(branchDealers, warrantyBranchDealers, true);
}
如何为该forEach
循环编写代码覆盖率。
测试用例代码:
dealerService.getBranchDealersForDealer("NACD", "USEAST", "SEATLE", "SEATLE");