集成测试最佳实践 [英] Integration Test Best Practice

查看:85
本文介绍了集成测试最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建集成测试时,什么是引入数据的最佳方法?

When creating integration tests, what is the best approach to introduce data?

应该使用sql脚本在测试的设置中创建数据,还是最好使用实际的业务对象来生成可供测试使用的数据.

Should sql scripts be used to create the data in the setup of the test or would it be better to use the actual business objects to generate data which can then be used by the tests.

任何帮助将不胜感激.

推荐答案

为自动化测试创建测试数据时,我会遵循一些规则,我发现这些规则可以帮助我完成可靠的测试,从而降低维护成本:

When creating test data for automated test there are a few rules I try to stick to and I find these rules help me achieve reliable tests that have a lower maintenance overhead:

  1. 避免将一个测试的输出作为另一测试的输入,即不要使用测试A为测试B创建测试数据
  2. 避免使用被测对象来创建测试数据,即如果您的测试模块A不使用模块A来创建任何测试的测试数据
  3. 以可靠且可重复的低成本方式创建测试数据,例如使用SQL脚本设置数据
  4. 在决定如何创建测试数据时,还应考虑如何删除测试数据,以便可以从干净的基本状态运行测试

在我的环境中,我在测试夹具或测试设置点使用SQL创建测试数据,然后在测试夹具或测试拆解点使用SQL清理测试数据.

In my environment I create test data using SQL at either the test fixture or test set-up point and then I clean out the test data using SQL at either the test fixture or test tear-down point.

这篇关于集成测试最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆