Testing 功能测试可以同时称为集成测试吗?

Testing 功能测试可以同时称为集成测试吗?,testing,Testing,这是zlib中example.c的一部分。我最初想使用check将此代码转换为单元测试,但后来我有点困惑: 这些测试是否低于功能测试?或者它们也可以称为集成测试或单元测试 test_compress(compr, comprLen, uncompr, uncomprLen); test_deflate(compr, comprLen); test_inflate(compr, comprLen, uncompr, uncomprLen); test_large_deflate(compr, co

这是zlib中example.c的一部分。我最初想使用check将此代码转换为单元测试,但后来我有点困惑:

这些测试是否低于功能测试?或者它们也可以称为集成测试或单元测试

test_compress(compr, comprLen, uncompr, uncomprLen);
test_deflate(compr, comprLen);
test_inflate(compr, comprLen, uncompr, uncomprLen);
test_large_deflate(compr, comprLen, uncompr, uncomprLen);
test_large_inflate(compr, comprLen, uncompr, uncomprLen);
test_flush(compr, &comprLen);
test_sync(compr, comprLen, uncompr, uncomprLen);
comprLen = uncomprLen;
test_dict_deflate(compr, comprLen);
test_dict_inflate(compr, comprLen, uncompr, uncomprLen);

单元测试实际上也可以是集成测试。如果您的测试单元访问外部资源,那么这是一个传统的集成测试。如果它访问其他单元,它也会作为集成测试的一种形式(模块间,不要与组件间/服务/数据库集成混淆)。后一种情况就是您正在展示的情况——函数计算其他人随后消费并进一步转换的东西


如果测试的目的是针对特定单元(如功能),但附带测试其他单元,则它也可作为集成测试。但是,如果除了测试的预期目标之外,没有其他功能被执行(如果需要,使用stub或mock作为辅助功能),那么它只是一个单元测试,而不是一个集成测试。这两种方法都没有错;这完全取决于你想要达到的控制水平和范围的宽度。调用的单元越少,控制就越多,但测试的范围就越小。

这对我来说很有意义。谢谢这个答案对我来说足够好了,unittest的流量非常低,我会关闭这个