I'm looking for information/guidelines on how to use io.cucumber.core.api.Scenario
interface?
I read through the API reference documentation and Official Cucumber-Java documentation and some scattered usage examples, but still couldn't figure out what is the correct way to use it, and what happens when I call methods of this interface.
Why would I like to find this info? I am maintaining a sizable automation framework, and moving it to use dependency injection for step classes. But the previous developer used scenario.write
as a logging tool and I was not sure how to refactor that, or what implementation to bind to Scenario
interface.
Upd. Here is an example of what I have in classes that that use Scenario.write
as logger.
// Let's assume that code below resides in some Java class that defines Gherkin steps
private Scenario scenario;
@Before()
public void before(Scenario scenario) {
this.scenario = scenario;
}
@Then("^Received XML file should match \"([^\"]*)\"$")
public void receivedXmlFileShouldMath(String expectedFilePath) {
// ignoring how we read expected file and where received file content is stored
scenario.write("Ignoring date field in xml message");
compareXml(expectedXml, actualXml)
}
If it is possible I would like to move Scenario injection to the class constructor, or use some other technique to still get the message in the report.