can we add doc_string from step definition(.java) instead of feature file?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020
11:25 AM
06-10-2020
11:25 AM
can we add doc_string from step definition(.java) instead of feature file?
We have a requirement in our Java based project to attach some runtime json/text data in doc string, which should be displayed in test report. do we have feature enabled? can you share some examples?
Example:
public void addDocString(Step step){
step.setDocString("text", "Some example doc string text", 1)
}
Example:
public void addDocString(Step step){
step.setDocString("text", "Some example doc string text", 1)
}
Labels:
- Labels:
-
Cucumber-JVM
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020
01:59 AM
06-15-2020
01:59 AM
This is currently not possible. It's not something we're likely to add support for either.
------
I'm the creator and lead developer of Cucumber Open.
I'm the creator and lead developer of Cucumber Open.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020
03:14 PM
06-15-2020
03:14 PM
I got the impression this wasn't a feature request but rather a "How do I do x" disguised as one.
To attach data
package io.cucumber.examples.java;
import io.cucumber.java.Before;
import io.cucumber.java.Scenario;
import io.cucumber.java.en.Given;
public class RpnCalculatorSteps {
private Scenario scenario;
@Before
public void after(Scenario scenario) {
this.scenario = scenario;
}
@Given("I log some data")
public void log_some_data(){
scenario.attach("{hello:\"World\"}", "application/json", "hell-world.json");
}
}
This then shows up in the report as:
Given I log some data
{hello:"World"}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2020
03:17 PM
06-15-2020
03:17 PM
Well spotted XY problem @mpkorstanje !
------
I'm the creator and lead developer of Cucumber Open.
I'm the creator and lead developer of Cucumber Open.
