Maven vs Command Line Differences

28 views
Skip to first unread message

Justin Radcliffe

unread,
Jun 22, 2016, 3:32:03 PM6/22/16
to Cukes
When building my project from maven, I can set my tag hierarchy from the feature order like:

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty","json:target/Cucumber-report/cucumber.json"}
                ,features={"src/test/resources/com/testcases/testsuite/gccx/common/login",
                        "src/test/resources/com/testcases/testsuite/gccx/activities",
                        "src/test/resources/onstar/testcases/testsuite/gccx/common/logout",}

                    ,tags = {"@login,@package,@logout"})

public class RunnerTest {
    public void runTest() {

    }
}   

Since I have my features broken out in an order I feel is appropriate and have common login and logout that should happen first and last.

Now that works building the pom and letting maven run the test.

When running from the command line though as :

java -cp lib\*;target\62100_Automation_KW-0.0.1-SNAPSHOT-jar-with-dependencies.jar cucumber.api.cli.Main --glue com.testcases C:\AutomationFrameworkKW\Automation_Framework\src\test\resources\com\testcases\testsuite\gccx --tags @login,@package,@logout --plugin pretty

This tries to run the package feature file first as that is in gccx/actvities and login is in gccx/login alphabetically.

Is there a way from the common line to have multiple feature files and have the running order?

Serguei Cambour

unread,
Jun 23, 2016, 4:34:08 PM6/23/16
to Cukes
As described in the following thread, you should avoid the coupling between your scenarios/features. If you don' care, the only working solution would be to rename your features to match the ascending order, e.g. 01_my_most_imporant.feature, 02_less_important.feature.

Justin Radcliffe

unread,
Jun 23, 2016, 7:42:04 PM6/23/16
to Cukes
Ok, thanks. What I was trying to do it run but tags rather than full feature files. So I could have a common feature for login, logout, in any directory and then have all my core scenarios else where named for that they are. Those could be broken out as well.

I think we will just have every feature in the same dir with 0001_login.feature 0002_core.feature 000N_core.feature 9999_logout.feature.

Then we can run by tags passing into the command line.

I would just like to see the command line run the tags in the order you put them not matter the name or where those features are in the features main folder/sub folders.

Serguei Cambour

unread,
Jun 24, 2016, 7:11:47 AM6/24/16
to cu...@googlegroups.com


Sent from my iPhone

On 24 Jun 2016, at 01:42, Justin Radcliffe <jus...@gmail.com> wrote:

Ok, thanks. What I was trying to do it run but tags rather than full feature files. So I could have a common feature for login, logout, in any directory and then have all my core scenarios else where named for that they are. Those could be broken out as well.

I think we will just have every feature in the same dir with 0001_login.feature 0002_core.feature 000N_core.feature 9999_logout.feature.

Then we can run by tags passing into the command line.

I would just like to see the command line run the tags in the order you put them not matter the name or where those features are in the features main folder/sub folders.

Once again, the real effect of your tests is when they are run in a random way and to be coupled with each other. If you need to execute some stuff before or after, the corresponding hooks are always there to do the job.


On Thursday, June 23, 2016 at 4:34:08 PM UTC-4, Serguei Cambour wrote:


On Wednesday, 22 June 2016 21:32:03 UTC+2, Justin Radcliffe wrote:
When building my project from maven, I can set my tag hierarchy from the feature order like:

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty","json:target/Cucumber-report/cucumber.json"}
                ,features={"src/test/resources/com/testcases/testsuite/gccx/common/login",
                        "src/test/resources/com/testcases/testsuite/gccx/activities",
                        "src/test/resources/onstar/testcases/testsuite/gccx/common/logout",}

                    ,tags = {"@login,@package,@logout"})

public class RunnerTest {
    public void runTest() {

    }
}   

Since I have my features broken out in an order I feel is appropriate and have common login and logout that should happen first and last.

Now that works building the pom and letting maven run the test.

When running from the command line though as :

java -cp lib\*;target\62100_Automation_KW-0.0.1-SNAPSHOT-jar-with-dependencies.jar cucumber.api.cli.Main --glue com.testcases C:\AutomationFrameworkKW\Automation_Framework\src\test\resources\com\testcases\testsuite\gccx --tags @login,@package,@logout --plugin pretty

This tries to run the package feature file first as that is in gccx/actvities and login is in gccx/login alphabetically.

Is there a way from the common line to have multiple feature files and have the running order?

As described in the following thread, you should avoid the coupling between your scenarios/features. If you don' care, the only working solution would be to rename your features to match the ascending order, e.g. 01_my_most_imporant.feature, 02_less_important.feature.

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to a topic in the Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cukes/-nDqEsOFisA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Björn Rasmusson

unread,
Jun 25, 2016, 4:56:40 AM6/25/16
to Cukes
Serguei Cambour wrote:


Sent from my iPhone

On 24 Jun 2016, at 01:42, Justin Radcliffe <jus...@gmail.com> wrote:

Ok, thanks. What I was trying to do it run but tags rather than full feature files. So I could have a common feature for login, logout, in any directory and then have all my core scenarios else where named for that they are. Those could be broken out as well.

I think we will just have every feature in the same dir with 0001_login.feature 0002_core.feature 000N_core.feature 9999_logout.feature.

Then we can run by tags passing into the command line.
Just to be clear, as this tread says, you do not run tags, tags = {"@login,@package,@logout"} is equivalent to tags = {"@logout,@package,@login"}


I would just like to see the command line run the tags in the order you put them not matter the name or where those features are in the features main folder/sub folders.

Once again, the real effect of your tests is when they are run in a random way and to be coupled with each other. If you need to execute some stuff before or after, the corresponding hooks are always there to do the job.


On Thursday, June 23, 2016 at 4:34:08 PM UTC-4, Serguei Cambour wrote:


On Wednesday, 22 June 2016 21:32:03 UTC+2, Justin Radcliffe wrote:
When building my project from maven, I can set my tag hierarchy from the feature order like:

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty","json:target/Cucumber-report/cucumber.json"}
                ,features={"src/test/resources/com/testcases/testsuite/gccx/common/login",
                        "src/test/resources/com/testcases/testsuite/gccx/activities",
                        "src/test/resources/onstar/testcases/testsuite/gccx/common/logout",}

                    ,tags = {"@login,@package,@logout"})

public class RunnerTest {
    public void runTest() {

    }
}   

Since I have my features broken out in an order I feel is appropriate and have common login and logout that should happen first and last.

Now that works building the pom and letting maven run the test.

When running from the command line though as :

java -cp lib\*;target\62100_Automation_KW-0.0.1-SNAPSHOT-jar-with-dependencies.jar cucumber.api.cli.Main --glue com.testcases C:\AutomationFrameworkKW\Automation_Framework\src\test\resources\com\testcases\testsuite\gccx --tags @login,@package,@logout --plugin pretty

The command line and using a JUnit runner class behaves exactly the same, but you specify the feature paths differently. Your command line is equivalent to
    features={"src/test/resources/com/testcases/testsuite/gccx"}

Using that in your @CucumberOptions would give the same behaviour running with maven as you got from running command line.
Specifying
    src\test\resources\com\testcases\testsuite\gccx\common\login src\test\resources\com\testcases\testsuite\gccx\activities src\test\resources\com\testcases\testsuite\gccx\common\logout
on the command line would give the same behaviour as you got from running with maven.

Regards
Björn
Reply all
Reply to author
Forward
0 new messages