如何编写具有动态值的场景大纲 ?
How to write Scenario Outlines with dinamic values ?
enter image description here例如:
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|
结果和总数是动态值。请问我该如何解决这个问题?
***Result*** is the total by status type.
***Total*** is the sum of the statuses.
当您说动态值时,我假设您是在 运行 期间获得的,或者换句话说,在您 运行 BDD 之前您不会知道这些值。如果是这种情况,您需要重新考虑如何编写 BDD。对于每一个价值,都应该有一个商定的结果。例如,如果状态被批准,那么对于结果和总计,您应该预先设置一个 defined/agreed 的值。
例如,您上面的 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 | |
|created | pending | |
|rejected | failed | [=10=] |
|confirmed| success | |
您不应期望测试中有动态值。您的测试数据应该以您始终期望预期结果的方式设置。
enter image description here例如:
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|
结果和总数是动态值。请问我该如何解决这个问题?
***Result*** is the total by status type.
***Total*** is the sum of the statuses.
当您说动态值时,我假设您是在 运行 期间获得的,或者换句话说,在您 运行 BDD 之前您不会知道这些值。如果是这种情况,您需要重新考虑如何编写 BDD。对于每一个价值,都应该有一个商定的结果。例如,如果状态被批准,那么对于结果和总计,您应该预先设置一个 defined/agreed 的值。
例如,您上面的 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 | |
|created | pending | |
|rejected | failed | [=10=] |
|confirmed| success | |
您不应期望测试中有动态值。您的测试数据应该以您始终期望预期结果的方式设置。