Reputation: 13
I am calling few APIs in beforefeature hook and below are the goals I want to achieve.
I can call the APIs from background of each feature class but to reduce the number of API calls I am trying to move them in beforefeature.
Can anyone please suggest a way to edit/publish the cucumber report from beforefeature. Thanks.
Upvotes: 1
Views: 450
Reputation: 17553
Basically as per gherkins standard verifying the result should be in Then statement, if this response is a like prerequisite of getting test data for script then it fine.
The main thing to understand here is the order of the operations:
Before Hook 1 -> Before Hook 2 -> ... -> Background -> Scenario
So background run after Hooks and before Scenario.
As you stated you are hitting the API in before then save there required property in any java bean and Assert them in background
2) You can publish the results of api response in cucumber report as below:
@After
public void afterScenario(Scenario scenario) {
scenario.write("Text you want to write in report");
}
Upvotes: 1