0

In Ruby, I can get the name of a Scenario file (e.g. "login.feature") using: scenario.file.to_s - (http://rdoc.info/gems/cucumber/Cucumber/Ast/HasLocation#file-instance_method)

Is there a way to do this in Cucumber-JVM?

  • For what purpose? If you just want to know where the file is for the failing cuke, you can see it in the report as long as you don't use '--no-source' in your parameter list. Or you can grep for your file. – Dave McNulla Apr 04 '14 at 06:12
  • I want to create a documentation of my system. If the test passes, I create a file like "login.feature.html", where login.feature is the name of the file that contains the current Scenario. – Christiane Okamoto Apr 04 '14 at 16:30
  • Cucumber already documents your results. I use cucumber reports as part of our FDA documentation. Try these links to see what comes closest to your needs. http://cukes.info/reports.html https://github.com/masterthought/cucumber-reporting https://groups.google.com/forum/#!topic/cukes/Xl6ZOxJVXs4 – Dave McNulla Apr 04 '14 at 20:21
  • I already created a custom one.. I needed it because I want to send this for clients, it has to be more customizable. That's why I was asking if somebody knew if that is a way to get the filename's of the scenario, like in cucumber for ruby. – Christiane Okamoto Apr 06 '14 at 19:25

1 Answers1

0

If you're using the junit runner, write your own formatter.

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "classpath:features/something.feature",
        format = "com.blah.PrintingFormatter",
        glue = "com.blah.steps")
public class CucumberTest {

}

Your PrintingFormatter should implement the gherkin.formatter.Formatter interface, specifically the uri method.

@Override
public void uri(String uri) {
    //do something
}

Add a println and you'll see the name of your feature file.

benkiefer
  • 739
  • 6
  • 10