Re: [Cucumber] How do I run a single cucumber feature or tag via Maven command line?

7,018 views
Skip to first unread message

Aslak Hellesøy

unread,
Jun 15, 2012, 2:52:26 PM6/15/12
to cu...@googlegroups.com




On 15 Jun 2012, at 19:48, David Lai <sbs...@gmail.com> wrote:

I'm having trouble figuring out how to run a single test via maven command line.  I can edit the @Cucumber.Options in the test runner class and give it a name or tags parameter.  But when I try to do the same using 'mvn test -dCucumber.Options="--name=MyFeature"' this does not work.  It'll give an error saying can't find that test "--name=MyFeature".  Using just:'mvn test' works and executes all the features.  I'd like to be able to run single features and feature by tags via the command line.


There was a thread about this in the past week.

Aslak

Thanks,

-- 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

Selenium Vietnam

unread,
Aug 10, 2015, 2:02:40 AM8/10/15
to Cukes
Dear all,

I have the same question. Anyone can help?

Javix

unread,
Aug 10, 2015, 4:21:42 AM8/10/15
to Cukes


Le vendredi 15 juin 2012 20:52:26 UTC+2, Aslak Hellesøy a écrit :




On 15 Jun 2012, at 19:48, David Lai <sbs...@gmail.com> wrote:

I'm having trouble figuring out how to run a single test via maven command line.  I can edit the @Cucumber.Options in the test runner class and give it a name or tags parameter.  But when I try to do the same using 'mvn test -dCucumber.Options="--name=MyFeature"' this does not work.  It'll give an error saying can't find that test "--name=MyFeature".  Using just:'mvn test' works and executes all the features.  I'd like to be able to run single features and feature by tags via the command line.


There was a thread about this in the past week.

Wh 

Javix

unread,
Aug 10, 2015, 4:24:47 AM8/10/15
to Cukes


On Friday, June 15, 2012 at 8:52:26 PM UTC+2, Aslak Hellesøy wrote:




On 15 Jun 2012, at 19:48, David Lai <sbs...@gmail.com> wrote:

I'm having trouble figuring out how to run a single test via maven command line.  I can edit the @Cucumber.Options in the test runner class and give it a name or tags parameter.  But when I try to do the same using 'mvn test -dCucumber.Options="--name=MyFeature"' this does not work.  It'll give an error saying can't find that test "--name=MyFeature".  Using just:'mvn test' works and executes all the features.  I'd like to be able to run single features and feature by tags via the command line.


There was a thread about this in the past week.

Aslak

Oups, bad keyboard operation :)))
Aslak, what if you taf a feaure to be executed and pass it to the cucumber options like that:

@CucumberOptions(tags="@TagA", glue="step_definitions", features ="features") ?

In this case running mvn test would just execute the specified feature.

Javix

unread,
Aug 10, 2015, 4:29:00 AM8/10/15
to Cukes


On Friday, June 15, 2012 at 8:52:26 PM UTC+2, Aslak Hellesøy wrote:




On 15 Jun 2012, at 19:48, David Lai <sbs...@gmail.com> wrote:

I'm having trouble figuring out how to run a single test via maven command line.  I can edit the @Cucumber.Options in the test runner class and give it a name or tags parameter.  But when I try to do the same using 'mvn test -dCucumber.Options="--name=MyFeature"' this does not work.  It'll give an error saying can't find that test "--name=MyFeature".  Using just:'mvn test' works and executes all the features.  I'd like to be able to run single features and feature by tags via the command line.


There was a thread about this in the past week.

Aslak

Thanks,

Sorry for the typo, it should be like that:

Aslak, what if you tag a feaure to be executed and pass it to the cucumber options like that: ...

@CucumberOptions(tags="@TagA", glue="step_definitions", features ="features") ?

Javix

unread,
Aug 10, 2015, 6:27:41 AM8/10/15
to Cukes


Le vendredi 15 juin 2012 20:52:26 UTC+2, Aslak Hellesøy a écrit :




On 15 Jun 2012, at 19:48, David Lai <sbs...@gmail.com> wrote:

I'm having trouble figuring out how to run a single test via maven command line.  I can edit the @Cucumber.Options in the test runner class and give it a name or tags parameter.  But when I try to do the same using 'mvn test -dCucumber.Options="--name=MyFeature"' this does not work.  It'll give an error saying can't find that test "--name=MyFeature".  Using just:'mvn test' works and executes all the features.  I'd like to be able to run single features and feature by tags via the command line.


There was a thread about this in the past week.

Aslak

Thanks,
Just tried to run it as follows and it worked for me:

mvn clean test -Dcucumber.options="--tags @user"

 I tagged a feaure as follows:

@user
Feature: Set user login
...


You can also specify the tag in your runner class:

@CucumberOptions(tags = "@user")

In this case, no need to pass via CLI.

Robert

unread,
Aug 15, 2015, 4:19:48 PM8/15/15
to Cukes


On Sunday, August 9, 2015 at 11:02:40 PM UTC-7, Selenium Vietnam wrote:
Dear all,

I have the same question. Anyone can help?


There are several ways to execute a single scenario from the command-line using Maven

  1. By using the scenario's name:
    mvn test -Dcucumber.options="--name '<include scenario name here>'"

  2. By referencing the scenario's line number in the feature file:
    mvn test -Dcucumber.options="classpath:features/login/login.feature:12"

    where login represents a directory contained within the features directory
  3. By reference a tag that has been placed on the scenario:
    mvn test -Dcucumber.options="--tags @my-unique-tag"

Reply all
Reply to author
Forward
0 new messages