Cucumber 中的数据驱动测试
我必须测试一个消息路由应用程序,其功能大致如下: - 消息发送到应用程序 - 应用程序检查消息 - 根据消息的内容将消息转发到某处
绝大多数测试用例几乎相同;生成特定类型的消息,将其加载到系统中,等待几秒钟,然后检查所需的目的地以确保消息被正确转发。
是否有一种推荐的方法来生成一个测试用例,并让它重复循环所有 (message, required_destination) 元组,而不是在 Cucumber 中生成数百个几乎相同的测试用例?为了便于维护,我更愿意将这些元组维护到 YAML 文件而不是数据库中,但这两种解决方案都可以。
I've got to test a message-routing application, whose functionality is broadly as follows:
- message gets sent to app
- app examines message
- message gets forwarded somewhere, based on the content of the message
The vast majority of test cases are near-identical; generate a particular type of message, load it into the system, wait a few seconds, then check the required destination to ensure that the message was forwarded correctly.
Rather than generate 100s of near-identical test cases in Cucumber, is there a recommended way to generate the one test case, and have it repeatedly cycle through all the (message, required_destination) tuples? I'd prefer to have these tuples maintained into a YAML file rather than a database, for ease of maintenance, but either solution would be fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该尝试使用示例场景大纲
正常场景
场景大纲
阅读更多:
https://github.com/cucumber/cucumber/wiki/Scenario-Outlines
You should try Scenario Outline using Examples
Normal Scenario
Scenario Outline
Read More:
https://github.com/cucumber/cucumber/wiki/Scenario-Outlines
我在黄瓜中没有这种情况,但我确实在规范中使用管道分隔文件进行海量数据测试,希望它会有所帮助:
您可以找到示例 此处为 DamerauLevenshteinMod 的说明 和 在 read_test_file
我不明白为什么同样的方法也不能用于黄瓜。
I dont have this kind of situation in cucumber, but I do use pipe separated files in specs for massive data testing, hope it will help:
You can find examples here in description of DamerauLevenshteinMod and here in read_test_file
I dont see why the same approach cannot be used for cucumber as well.