可以说这是我的 .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
所以您上面的示例可能混淆了一些 Then
和 When
。
作为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/