我经常发现将2个职责合并为1的方法,比如CreateOrUpdate方法,我想知道,我应该测试集成测试中的每一个方法吗?当我们测试这个方法的时候,不是已经在测试它里面的所有东西了吗?我们可以只创建两个测试用例,一个用于更新,另一个用于创建?
以下是我的源代码:
def distribute_transaction(self,
depth_purchase_request_id: int,
bulk_reference_lead_id: int,
customer_requested: Customer,
r123_depth_purchase: DepthPurchaseRequestViewModel
):
depth_bulk_purchases = self._depth_bulk_purchase_repo.get_all_by_depth_purchase_id(depth_purchase_request_id)
for depth_bulk_purchase in depth_bulk_purchases:
if depth_bulk_purchase.customer_id == customer_requested.id:
continue
lead_depth_bulk_purchase_exists = self._lead_depth_bulk_purchase_repo.get_by_depth_bulk_purchase(depth_bulk_purchase.id)
if not lead_depth_bulk_purchase_exists:
self.create_lead_and_transaction(
depth_bulk_purchase,
bulk_reference_lead_id,
LeadStageConstants.PACKAGE_ACTIVE,
r123_depth_purchase)
else:
self.update_lead_and_transaction(
depth_bulk_purchase,
LeadStageConstants.PACKAGE_ACTIVE,
r123_depth_purchase,
lead_depth_bulk_purchase_exists)
def create_lead_and_transaction(...):
...
def update_lead_and_transaction(...):
... 发布于 2021-08-17 04:07:47
无集成测试是指将错误和非错误分组,并将它们作为一组进行测试,分别解决每个错误,看看它是否不是导致错误的唯一原因,我建议您查阅集成测试的ISTQB标准。
https://stackoverflow.com/questions/68811429
复制相似问题