简体   繁体   English

如何用动态值编写场景大纲?

[英]How to write Scenario Outlines with dinamic values ​?

enter image description here for example:例如在此处输入图像描述

Scenario Outline:
Given the user is logged into Home Operations
When searching for "<status>"
Then the "<result>" and "<total>" are presented

Examples:
| status  |
|approved |
|created  |
|rejected |
|confirmed|

The result and total are dinamic values.结果总数是动态值。 How can I fix this, Please?请问我该如何解决这个问题?

***Result*** is the total by status type.
***Total*** is the sum of the statuses.

When you say dynamic value, I presume you are getting that during run time or in other words you wouldn't know the values until you run the BDD.当您说动态值时,我假设您是在运行时获得的,或者换句话说,在运行 BDD 之前您不会知道这些值。 If that's the case, you need to reconsider how you write your BDDs.如果是这种情况,您需要重新考虑如何编写 BDD。 For every value there should be an agreed outcome.对于每一个价值,都应该有一个商定的结果。 For an example, if the status is approved then for the result and total you should have a value that is defined/agreed upfront.例如,如果状态被批准,那么对于结果和总计,您应该有一个预先定义/商定的值。

For an example, your above BDD could be rewritten as例如,您的上述 BDD 可以重写为

Scenario Outline: 
Given the user is logged into Home Operations 
When searching for "<status>" 
Then the "<result>" and "<total>" are presented

Examples:
| status  | result  |total|
|approved | success | $20 |
|created  | pending | $20 |
|rejected | failed  | $0  |
|confirmed| success | $20 |

You shouldn't be expecting dynamic values in your test.您不应该期望测试中有动态值。 Your test data should be set up in such a way that you always expect an expected outcome.您的测试数据应该以您始终期望预期结果的方式设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM