testing - Specflow - 如何返回上一步

标签 testing bdd specflow

可以说这是我的 .featurefile ,在非常步骤的后面绑定(bind)了一个方法..

Given The system administrator sends a list of Tracks
And The system is at CreateCWRFile method
And The system sends "name", "caeID" & "ver" to generate HDR Line   
Then The system generates GRH Line
Then The system generates track Revision Line   
Then The system generates track SPU Line
Then The system generates track SPT Line
Then The system generates and verifies SWT, PWR & SWR Lines each writer of track

假设我的测试在第 5 行,即第 5 步,在某些情况下我想回到第 2 步,如何做......

最佳答案

冒着重复的风险Specflow step definition mapping with wildcard attribute我认为您正在努力实现目标。

SpecFlow善于描述;

  • 您的系统应该处于的状态 - 即 Given
  • 您要执行的操作 - 即 When
  • 以及之后状态应该是什么样的,即 Then

所以您上面的示例可能混淆了一些 ThenWhen

作为nemesv在评论中指出,您可能应该有不止一种情况来处理分支。看看How to run gherkin scenario multiple times举个例子。

您唯一的其他选择是从多个步骤构建您的场景并测试您每次都处于正确的状态,例如

Given the traffic light is red
When the light changes
Then the light should be amber
When the light changes
Then the light should be green
When the light changes
Then the light should be amber
When the light changes
Then the light should be red

祝你好运:-)

关于testing - Specflow - 如何返回上一步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17364240/

相关文章:

unit-testing - 服务级别单元测试与端到端测试之间的区别

c# - 如何使用 MSTest 从命令行运行 SpecFlow 场景?

php - 测试具有深层嵌套依赖关系的类的行为

c# - Selenium C# - 将表值与可用值进行比较

testing - 如何在 Specflow 3.0 [BeforeTestRun] static Hook 中访问 TestContext

django - 如何在 django 项目中使用 Selenium(LiveServerTestCase) 并行运行测试?

rest - 无法根据内容类型 : application/x-www-form-urlencoded 的发布请求创建模拟

python - Django Form Clean 方法测试错误

用于检查具有特定类的元素的父级的 cucumber 测试

SpecFlow ScenarioContext.Current 总是返回 null