Shabar
Shabar

Reputation: 2823

Pass tags via build.gradle instead thro RunCukesSpec

When I pass tags in the following manner it works perfectly.

package features

import org.junit.runner.RunWith
import cucumber.junit.Cucumber
import geb.junit4.GebReportingTest

@RunWith(Cucumber.class)
@Cucumber.Options(format = ["pretty", "html:build/cucumber", "json-pretty:build/cucumber-report.json"])
                            ,tags = ["@login_neg"])

class RunCukesSpec extends GebReportingTest {}

But my goal is to config same thing via build.gradle & if it succeeds then pass through command line. I tried below as the initial step and hope that by running gradle test in command line to get the expected results.

test {
    testLogging.showStandardStreams = true

    args = ['--tags', '@login_neg',
            '--format', 'html:build/cucumber',
            '--format', 'json-pretty:build/cucumber-report.json',
            '--format', 'pretty']

}

In this case all the tags are running though.

Tried this as well. But no luck gradle test -DCucumber.Options="--tags @login_neg"

versions:

------------------------------------------------------------
Gradle 1.9
------------------------------------------------------------

Build time:   2013-11-19 08:20:02 UTC
Build number: none
Revision:     7970ec3503b4f5767ee1c1c69f8b4186c4763e3d

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.7.0_45 (Oracle Corporation 24.45-b08)
OS:           Windows 7 6.1 amd64

Upvotes: 2

Views: 3506

Answers (1)

Andrew Keely
Andrew Keely

Reputation: 166

You can pass options as System properties by updating your build.gradle file with:

test {
  systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
}

This configuration will pass the cucumber.options System property from the Gradle JVM to the JVM running the tests.

You can then run gradle test -Dcucumber.options="--help" to see the available options for that System property (replace --help with your options).

Upvotes: 5

Related Questions