如何测试复杂功能的各个部分例如许多子操作的集成

问题描述

想象一下这种设计具有一个功能(我认为从技术上讲这是一种程序设计):

def run_feature(input_tsv):
    """
    Performs a bunch of data transformations and finally outputs a particular calculation

    :param str input_tsv: Path to input tsv
    :return int: Final calculated value
    """
    post_op_1 = _operation_1(input_tsv)
    post_op_2 = _operation_2(post_op_1)
    post_op_3 = _operation_3(post_op_2)
    # ... Imagine several more of these sub-operations
    return _operation_N(post_op_N_minus_1)

# Code for each _operation_#

我对每个_operation_#函数都有测试,但是对run_feature没有任何实际测试。因此,我想知道如何确保所有部件正确集成?更为复杂的是,input_tsv包含许多列和情况的潜在组合。

一些想法:

  1. 我可以模拟每个部分并验证是否调用了每个部分。这很容易,但是它似乎确实将这种代码的未来锁定在该设计中。
  2. 我可以尝试生成尽可能多的input_tsv情况,并希望我不会错过任何潜在的集成问题。这似乎是不切实际的,并且将来也很难更新。
  3. 1和2的某种组合以确保所有部分都被调用,而且还可以在一些常见情况下按预期生成正确的最终返回值(例如,我可以手动预测正确答案的input_tsv)。
  4. li>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)