为 ATDD 式自动化设置数据的最佳方法是什么?
我假设大多数实现都有一组已知数据,每次测试运行时都会重新启动这些数据。我认为这里有一些基本的思想流派。
- 有测试代码,使用应用程序调用来生成数据。
- 让测试代码通过直接数据存储调用手动旋转数据。
- 让该基本数据集包含运行测试所需的一切。
我认为很明显#3 是最难维护的方法..但我仍然很好奇是否有人成功使用它。也许您可以拥有适用于各种场景的数据库,并从测试代码中删除/添加它们。
I assume that most implementations have a base set of known data that gets spun up fresh each test run. I think there are a few basic schools of thought from here..
- Have test code, use application calls to produce the data.
- Have test code spin up the data manually via direct datastore calls.
- Have that base set of data encompass everything you need to run tests.
I think it's obvious that #3 is the least maintainable approach.. but I'm still curious if anyone has been successful with it. Perhaps you could have databases for various scenarios, and drop/add them from test code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于数据类型和您的域。当架构还不稳定时,我进行了一次不成功的尝试。我们不断遇到向新的和更改的列添加数据的问题,这总是阻碍测试。
现在,我们成功地使用了起始状态数据,其中数据集很大程度上是固定的、稳定的模式,并且所有测试都需要处于相同的状态。 (例如邮政编码数据库)
对于大多数其他内容,测试负责自行设置数据。这对我们有用!
It depends on the type of data and your domain. I had one unsuccessful attempt when the schema wasn't stable yet. We kept running into problems adding data to new and changed columns which bricked the tests all the time.
Now we successfully use starting state data where the dataset will largely be fixed, stable schemas and required in the same state for all tests. (e.g. A postcode database)
for most other stuff the tests are responible for setting up data themselves. That works for us!