Jrawr Jrawr - 1 year ago 155
Java Question

Dynamic Feature File allocation in Cucumber JVM

I'm creating an executable jar file for some of my less tech literate coworkers to run tests without having to use the command line. It's a simple gui where they select the features they want to test and the step library is packaged within.

It works fine except for one small problem. At the moment I have to specify where I call the feature files from. Right now I have this set to look for a

features= {"c://Features"}
folder and run whatever is in there. I would like this to be more dynamic so that they don't have to create feature folders and, using a variable I can generate through the gui they can point to whatever file they want.

My current workaround is that I simply read from what ever file they choose and create a copy within the features folder which is cleaned after every test. This is not optimal and I would like to allow my users to point to whatever folder they wish and run feature files from that folder as some of our clients don't allow us to modify their c drive. I can still write into the folder they select and create temporary file copies, that's fine. But the annotation won't let me pass in a variable, I get this error instead.

The value for annotation attribute CucumberOptions.features must be a constant expression

Answer Source

You can use QMetry Automation Framework to run your gherkin. With QAF gherkin client you will be able to configure your features to run from xml configuration file. there you can specify one of more dir or feature file to run as well as you can apply filter, or you can configure your tests to run on different platforms. Here is the sample xml configuration file

<test name="Gherkin-QAF-Test">
   <parameter name="scenario.file.loc" value="resources/features" />
      <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />

More over you can set scenario.file.loc as command line argument or in properties file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download