我有以下我想在黄瓜中测试的功能。但是,我只想处理一次输入文件(@Given 在下面的功能中)。但是,它似乎每次都在执行@Given 步骤。是否可以仅在以下功能中执行此 @Given 一次?
@fileValidation
Scenario Outline: File Validation
Given a file is uploaded with name "something.csv"
Then response filename created should not match input filename "something.csv"
And reason for errors should be "<Reason>" with error code "<Error code>" for row with RequestId "<RequestId>"
Examples:
| RequestId | Error code | Reason |
| 123 | 101 | Failure 1 |
| 124 | 102 | Failure 1; Failure 2 |
我还通过删除 Given 步骤尝试了之前和之后的钩子,但没有运气。
我也在钩子之前尝试过,但对于示例中的每一行,它仍然会进入这个循环。
@Before("@fileValidation")
public void file_is_uploaded() throws Throwable {
String fileName = "something.csv";
processInputFile(fileName);
}
@After("@fileValidation")
public void clear() {
outputFileName = null;
}
在功能文件中我有这样的东西:
@fileValidation
Scenario Outline: File Validation
Background: Read the uploaded file "something.csv"
Then response filename created should not match input filename "something.csv"
And reason for errors should be "<Reason>" with error code "<Error code>" for row with RequestId "<RequestId>"
Examples:
| RequestId | Error code | Reason |
| 123 | 101 | Failure 1 |
| 124 | 102 | Failure 1; Failure 2 |