Search code examples
maventestinggroovycommand-linegeb

geb passing test case as a parameter from maven commandline


How do I pass the test case to geb via maven commandline:

I have a test case class named GebishOrgSpec2.groovy I want to pass this test case maven and let geb run it over the command line. I am having successful build but no run of the test case How do I solve this problem?

This is my pom.xml

  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19</version>
        <configuration>
          <includes>
            <include>${inc.TestCase}</include>
          </includes>
          <systemPropertyVariables>
            <geb.build.reportsDir>target/test-reports/geb</geb.build.reportsDir>
          </systemPropertyVariables>
        </configuration>
      </plugin>

I have tried the following codes and they are all not running the testcase

mvn -Dinc.TestCase=GebishOrgSpec2.groovy test
mvn -Dinclude=GebishOrgSpec2.groovy test
mvn install -Dinc.TestCase=GebishOrgSpec2.groovy 
mvn install -Dinclude=GebishOrgSpec2.groovy 

I have tried these links How to run Geb TestCases from windows command line?

Grails geb getting parameters from commandline

Geb exception when running tests in maven

they are all not working

System.getProperty("inc.TestCase") is returning null as well I want to add that if I add the test case directly into the pom it does run successfully can you please help


Solution

  • Don't use in-/excludes in your POM for something you want to do from the command line. It is much easier, both for

    This works beautifully for Spock/Geb tests.