You can specify tags using the @Feature annotation:
@RunWith(Cucumber.class)
@Feature(value="your/package", tags={"@focus"})
We will probably rename the @Feature annotation to @Opts in the next
release. Since the JUnit runner now can run a whole bunch of features
(no need to have a class per feature), it makes more sense to use this
annotation to pass general options to Cucumber. -Just like you can
when you are using the command-line interface.
Aslak
> Sorry if the question seems trivial, I searched this forum and Google
> thoroughly to no avail.
>
> /Svante
>
> --
> 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 http://groups.google.com/group/cukes?hl=en.
>
On an empty test class. Like this:
https://github.com/cucumber/cucumber-jvm/blob/master/picocontainer/src/test/java/cucumber/runtime/java/picocontainer/RunCukesTest.java
> And is it to mark a feature with the @focus tag or
> is it to run features with the @focus tag?
That would run all features that are tagged with @focus
> Does it work for both maven and JUnit? What if I want to run different
> tags with mavne than with JUnit?
>
Cucumber doesn't know what launched JUnit (and neither does JUnit). So
it works with anything that can run a JUnit test, i.e. Ant, Maven,
your IDE...
> And do I still mark features with "@[tag]" in .feature files like
> this:
>
> @focus
> Feature: test-feature
> Given ...
> When ...
> Then ...
>
Yes
> To run the test class with Maven configure the surefire plugin (or
> failsafe if you use that) to run the RunMyTag class as test.
> This can be done in the pom.xml with:
>
> <plugins>
> <plugin>
> <artifactId>maven-surefire-plugin</artifactId>
> ...
I usually run cucumber features with the maven-failsafe-plugin
(http://maven.apache.org/plugins/maven-failsafe-plugin/) bound to the
integration-test phase. As it says in its web page, "The Failsafe
Plugin is designed to run integration tests while the Surefire Plugins
is designed to run unit tests."
This is an extract of my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<includes>
<include>unit/**/*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<includes>
<include>component/**/*.java</include>
<include>specification/functional/*.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Tests in the package hierarchies unit and component are plain JUnit
tests, instead those in the specification.functional hierarchy are run
with the Cucumber runner like in your project (yes, I use non-standard
package hierarchies for tests).
I don't know if it makes sense :-)
--
Paolo
I have been hesitant to get into cuke-jvm since it sounds like
tests somehow need to be bound to JUnit classes, which sounds like
more overhead than cuke4duke (which we've been using) has. E.g.
with cuke4duke I can select tags on the mvn cmd line with no
hardwired profiles. (Of course I know cuke4duke is EOL'd.)
If anyone would care to compare/contrast cuke-jvm with cuke4duke and
jBehave, I'd appreciate it.
Thanks,
Bill
> This example seems to indicate that with cuke-jvm, one needs an
> empty class with a tag in it in order to use a tag to select tests
> to run?
Cucumber-JVM has 2 different runners. A JUnit runner and a Command Lin
Interface (CLI) runner.
The JUnit runner requires a JUnit test class, as that is what JUnit
needs to run anything.
The CLI runner does not require a JUnit class. See the
jruby/jython/picocontainer modules' pom.xml for examples.
> And that class needs to be called out explicitly in pom.xml?
>
No it does not. Maven automatically runs all JUnit tests (including
those annotated with @RunWith(Cucumber.class)) as long as you follow
Maven's naming conventions.
> I have been hesitant to get into cuke-jvm since it sounds like
> tests somehow need to be bound to JUnit classes, which sounds like
> more overhead than cuke4duke (which we've been using) has.
You're misinformed. And if you choose to use the JUnit runner, a
single class is sufficient to run all features.
I wouldn't call a single empty class much overhead.
> E.g.
> with cuke4duke I can select tags on the mvn cmd line with no
> hardwired profiles.
The CLI runner lets you do the same.
> (Of course I know cuke4duke is EOL'd.)
>
> If anyone would care to compare/contrast cuke-jvm with cuke4duke and
> jBehave, I'd appreciate it.
>
That would be great!
Aslak
It just isn't used in the poms.
> Is it really possible to run only specific tagged features from the
> Maven CLI?
Sure, you could `mvn -Dtags=@foo` and reference the `tags` system
property in your pom.
Aslak
Hi aslak , I am working on cucumber and now i have a question of how can i use to run specific tests run using Maven . can you please give some few tags where i can run at maven .
--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi Aslak