On Monday, 10 December 2012 at 23:07, Tim Mertens wrote:
Hi,
I am using cucumber-jvm and am wondering if/how I can tell Cucumber what feature files to run at runtime,
rather than by specifying the features at compile time:
@RunWith(Cucumber.class)
@Cucumber.Options(features={"classpath:com/test/my/feature.feature"})
public class RunTest {}
For reasons specific to my environment, I am using the following code to execute specific test cases from an executable jar:
junitRunner.run(com.test.RunTest.class);
I can use custom @RunWith(Cucumber.class) classes like the one above to run specific feature files, but I would really like to be able to supply a list of .feature files (or even an input stream or whatever else it needs) to the test runner to define which test cases to execute, or I could call the test runner for every feature file if needed. I want to avoid having to statically define the feature files in Java code.
If anyone has any idea how I could do this or can point me in the right direction, please let me know!
Thanks!
Tim
--
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
cucumber.api.cli.Main.main(opts);
JUnitCore junitRunner = new JUnitCore();
Result run;
run = junitRunner.run(com.tim.tests.RunTest.class);
for(Failure failure : run.getFailures()) {
logger.error(failure.getMessage(), failure.getException());
}
System.setProperty("cucumber.options", " --monochrome");
run = junitRunner.run(com.tim.tests.RunTest.class);
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.1</version>
</dependency>
I tried setting the cucumber.options System Property, but when I do I receive an exception. For example:
System.setProperty("cucumber.options", " --monochrome");
run = junitRunner.run(com.lyonscg.qa.taf.tests.magento.RunTest.class);
Results in the following exception, even though I am not specifying any glue or feature file options in the cucumber.options System Property:
Hi,
I am using cucumber-jvm and am wondering if/how I can tell Cucumber what feature files to run at runtime, rather than by specifying the features at compile time:
@RunWith(Cucumber.class)
@Cucumber.Options(features={"classpath:com/test/my/feature.feature"})
public class RunTest {}
For reasons specific to my environment, I am using the following code to execute specific test cases from an executable jar:
junitRunner.run(com.test.RunTest.class);
I can use custom @RunWith(Cucumber.class) classes like the one above to run specific feature files, but I would really like to be able to supply a list of .feature files (or even an input stream or whatever else it needs) to the test runner to define which test cases to execute, or I could call the test runner for every feature file if needed. I want to avoid having to statically define the feature files in Java code.
If anyone has any idea how I could do this or can point me in the right direction, please let me know!
Thanks!
Tim
Thanks Aslak,
I am looking at the usage document but it is not clear how I can use the cucumber.options property to accomplish my objective. I can build an options String[] and pass it to the cli main:
cucumber.api.cli.Main.main(opts);
But there are a couple problems with this approach:
- The glue "-g" option allows file paths only and does not allow classpath references
On Wed, Dec 12, 2012 at 9:20 PM, Tim Mertens <t...@filmchicago.org> wrote:
I tried setting the cucumber.options System Property, but when I do I receive an exception. For example:
System.setProperty("cucumber.options", " --monochrome");
run = junitRunner.run(com.lyonscg.qa.taf.tests.magento.RunTest.class);
You shouldn't be using a space in the arguments. Try "--monochrome".
On Wed, Dec 12, 2012 at 8:49 PM, Tim Mertens <t...@filmchicago.org> wrote:
Thanks Aslak,
I am looking at the usage document but it is not clear how I can use the cucumber.options property to accomplish my objective. I can build an options String[] and pass it to the cli main:
cucumber.api.cli.Main.main(opts);
But there are a couple problems with this approach:
- The glue "-g" option allows file paths only and does not allow classpath references
Yes it does. Try --glue classpath:some/dir/in/your/class/path
System.setProperty("cucumber.options", "--glue com.tests.glue classpath:com/tests/HelloWorld.feature");
run = junitRunner.run(com.tests.vanillaTest.RunTest.class);
package com.tests.vanillaTest;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@Cucumber.Options( format={"pretty","html:target/cucumber", "json-pretty:target/cucumber-report.json"} )
public class RunTest {
}
public class RunTest {
public RunTest() { }
}
Hi,
I am using cucumber-jvm and am wondering if/how I can tell Cucumber what feature files to run at runtime, rather than by specifying the features at compile time:
On Thursday, 20 December 2012 at 11:00, Tim Mertens wrote:
Aslak,
I got this working. From my main() class where I execute the tests, here is an example:
System.setProperty("cucumber.options", "--glue com.tests.glue classpath:com/tests/HelloWorld.feature");
run = junitRunner.run(com.tests.vanillaTest.RunTest.class);
My RunTest class is a vanilla test class with only the format specified so I can pass whatever glue and features to it that I need to:
package com.tests.vanillaTest;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@Cucumber.Options( format={"pretty","html:target/cucumber", "json-pretty:target/cucumber-report.json"} )
public class RunTest {
}
I did get some weird errors at first from the Cucumber constructor about not being able to call the super() constructor of the RunTest class for some reason. I added an empty constructor and it resolved it but as you can see in my example above, when I removed the constructor later on the tests continued running. I have no idea why it stopped then started working again, but adding the constructor like below seemed to resolve the issue.
Unfortunately since it is working now, I do not have a copy of the error to post.
public class RunTest {
public RunTest() { }
}
Cheers!
Tim
On Monday, December 10, 2012 5:07:11 PM UTC-6, Tim Mertens wrote:Hi,
I am using cucumber-jvm and am wondering if/how I can tell Cucumber what feature files to run at runtime, rather than by specifying the features at compile time:
@RunWith(Cucumber.class)
@Cucumber.Options(features={"classpath:com/test/my/feature.feature"})
public class RunTest {}
For reasons specific to my environment, I am using the following code to execute specific test cases from an executable jar:
junitRunner.run(com.test.RunTest.class);
I can use custom @RunWith(Cucumber.class) classes like the one above to run specific feature files, but I would really like to be able to supply a list of .feature files (or even an input stream or whatever else it needs) to the test runner to define which test cases to execute, or I could call the test runner for every feature file if needed. I want to avoid having to statically define the feature files in Java code.
If anyone has any idea how I could do this or can point me in the right direction, please let me know!
Thanks!
Tim
--