如何为系统测试创建测试数据 - 使用系统接口与数据库插入?
我们有几个网络服务系统(cxf 和 hibernate)。 Web 服务由 webfrontends(rails) 使用。
我想用水豚编写一些自动化集成测试,为了测试正确的工作流程,我们需要数据库中的一些测试数据。由于数据库模型相当复杂,用sql创建和维护测试数据会非常困难。
另一种选择是使用 Web 服务本身来设置一些数据,即在测试设置中我可以使用一些“createCustomer”接口来使用应用程序提供的业务功能。
有人对测试数据的设置有一些经验吗?就我个人而言,我不喜欢使用业务接口创建测试数据的方法,因为我会将前端测试耦合到流程,而这实际上并不相关。
We have a couple of webservice systems(cxf and hibernate). The webservices are used by webfrontends(rails).
I would like to write some automated integrations test with capybara, and in order to test the correct workflow, we need some testdata in the database. Since the db model quite complex, it would be very hard to create and meintain the test data with sql.
Another option would be to use the webservices itself to setup some data, i.e. in the setup of the test I could use some "createCustomer" interface to use business functionality provided by the application.
Does anyone has some experiences with the setup of test data? Personally I dont like the approach to use the business interface to create test data, since I would couple the frontend test to a process, which are not really related.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几个想法:
- 使用SQL脚本(我知道你写起来会很困难,但是IME,SQL脚本很容易设置,易于阅读和维护)
- 使用 RDBMS 的导入/导出实用程序(例如 Oracle 的 impdp/expdp)
- 为您的 RDBMS 设置虚拟机,并在每次运行测试时回滚到快照
A couple of ideas:
- use SQL scripts (I know you've written it would be very hard, but IME, SQL scripts are easily set up, easy to read and maintain)
- use your RDBMS's import/export utility (e.g. impdp/expdp for Oracle)
- setup a virtual machine for your RDBMS, and rollback to a snapshot every time when running the test