如何设计数据驱动的依赖场景测试? [英] How to design data driven dependent scenarios testing?
问题描述
我阅读了编写依赖测试场景的非最佳实践. 但是,如果应用程序受到大量数据驱动并操纵(创建,多个更新流,从逻辑上删除)数据,该怎么办?基本上,我们要最小化:
I read its NOT best practice to write dependent test scenarios. But what if an application is heavily data-driven and manipulates (creates, multiple update flows, logically deletes) data. Basically, we want to minimize:
- 测试每个相关方案的数据创建(例如,更新需要首先创建数据)
- 重新执行步骤
- 整个测试套件执行时间
问题:为了控制线程的执行,我可以扩展处理@ parallel = false的空手道核心类并添加考虑取决于场景"的自定义代码吗?有更好的/替代设计吗?请提出建议.
Question: In order to control the execution of threads, can I can extend Karate core classes which handles @parallel=false and add custom code which considers 'Depends on Scenario' ? Is there a better/alternate design? Please suggest.
示例:
- 场景1:创建T1,T2 [平行]
- 场景2:创建T3 [平行]
- 场景3:创建R1(T1和T2之间的关系)进行更新 T1,T2 [顺序:等到1]
- 场景4:创建R2(T1和T3之间的关系)进行更新 T1,T3 [顺序:等到1,2]
- 场景5:删除更新T1,T2的R1 [顺序:等到 1,3]
- 场景6:删除T1,从而删除R1,R2 [顺序:等到 1,4,5]
- Scenario1 : Create T1, T2 [Parallel]
- Scenario2 : Create T3 [Parallel]
- Scenario3 : Create R1(relationship between T1 and T2)which updates T1, T2 [Sequential: wait until 1]
- Scenario4 : Create R2(relationship between T1 and T3) which updates T1, T3 [Sequential:wait until 1,2]
- Scenario5 : Delete R1 which updates T1,T2 [Sequential: wait until 1,3]
- Scenario6 : Delete T1 which deletes R1,R2 [Sequential: wait until 1,4,5]
推荐答案
您必须:
a)将流"写为首先设置数据(这是Background
的目的)并测试所有预期条件
a) write "flows" that set up data at the start (this is what a Background
is for) and test all the expected conditions
b)编写智能"测试.并且不受数据库启动状态的影响.例如,执行GET,查看已有多少客户,然后计算预期数量.但这可能会受到并行线程的影响,除非每个线程都设计为针对不同的客户群(例如按组织划分)
b) write tests that are "smart" and are immune to the starting state of the database. for example, do a GET, see how many customers already exist, and then calculate expected count. but this can be affected by parallel threads unless each thread is designed to work on a different set of customers (partition by e.g. organization)
作为提醒,请阅读以下内容: https://github.com/intuit/karate#脚本结构
As a reminder, read this: https://github.com/intuit/karate#script-structure
这篇关于如何设计数据驱动的依赖场景测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!