【问题标题】:Should I test every single method in Integration Test?我应该测试集成测试中的每一个方法吗?
【发布时间】:2021-08-17 03:45:00
【问题描述】:

我经常发现像 CreateOrUpdate 方法这样将 2 个职责合并为 1 个职责的方法,我想知道,我应该在集成测试中测试每个方法吗?是不是我们测试这个方法的时候已经在测试里面的所有东西了?我们可以创建 2 个测试用例,1 个用于更新,1 个用于创建?

这是我的源代码:

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(...):
    ...   

【问题讨论】:

    标签: python unit-testing integration-testing


    【解决方案1】:

    没有集成测试是将错误和非错误分组并将它们作为组进行测试,分别解决每个错误以查看它是否不是导致错误的唯一原因,我建议查找集成测试的 ISTQB 标准。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-27
      • 1970-01-01
      • 2018-01-21
      • 2012-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多