[JVM] How to get Maven to run Cucumber-JVM tests using Groovy glue

1,251 views
Skip to first unread message

Mike Howells

unread,
Apr 25, 2013, 7:35:09 PM4/25/13
to cu...@googlegroups.com
How do you set up a POM to get Cucumber-JVM to execute feature tests using Groovy glue code in the test phase?

Also, how do you add the option to only execute one feature file in a folder, rather than always executing all of them?

The installation instructions show how to add dependencies but that doesn't seem to add Cucumber to the test phase, and the page on running tests is rather unhelpful.

I've tried adding a JUnit wrapper but that doesn't get picked up by Maven either:

@RunWith(Cucumber.class)
@Cucumber.Options(features={"src/test/features"},
                  glue={"src/main/groovy/com/example/mytesting/glue"},
                  format={"pretty",
                          "json:target/results.json",
                          "html:target/cucumber",
                          "junit:target/cucumber/junit.xml"})
public class TestFeatures
{
}

Aslak Hellesøy

unread,
Apr 25, 2013, 8:22:19 PM4/25/13
to cu...@googlegroups.com

On Friday, 26 April 2013 at 00:35, Mike Howells wrote:

How do you set up a POM to get Cucumber-JVM to execute feature tests using Groovy glue code in the test phase?
Can you create an issue on github and request for an example to be added?

Aslak
Also, how do you add the option to only execute one feature file in a folder, rather than always executing all of them?

The installation instructions show how to add dependencies but that doesn't seem to add Cucumber to the test phase, and the page on running tests is rather unhelpful.

I've tried adding a JUnit wrapper but that doesn't get picked up by Maven either:

@RunWith(Cucumber.class)
@Cucumber.Options(features={"src/test/features"},
                  glue={"src/main/groovy/com/example/mytesting/glue"},
                  format={"pretty",
                          "json:target/results.json",
                          "html:target/cucumber",
                          "junit:target/cucumber/junit.xml"})
public class TestFeatures
{
}

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

Mike Howells

unread,
Apr 25, 2013, 8:47:23 PM4/25/13
to cu...@googlegroups.com


On Friday, 26 April 2013 10:22:19 UTC+10, Aslak Hellesøy wrote:

On Friday, 26 April 2013 at 00:35, Mike Howells wrote:

How do you set up a POM to get Cucumber-JVM to execute feature tests using Groovy glue code in the test phase?
Can you create an issue on github and request for an example to be added?

Aslak

Mike Howells

unread,
Apr 25, 2013, 8:50:05 PM4/25/13
to cu...@googlegroups.com


On Friday, 26 April 2013 10:22:19 UTC+10, Aslak Hellesøy wrote:

On Friday, 26 April 2013 at 00:35, Mike Howells wrote:

How do you set up a POM to get Cucumber-JVM to execute feature tests using Groovy glue code in the test phase?
Can you create an issue on github and request for an example to be added?

Aslak


Note that the Groovy example POM assumes that ${basedir}/bin/cucumber-groovy.jar exists, but Maven doesn't seem to install that when it downloads dependencies.

Aslak Hellesøy

unread,
Apr 25, 2013, 8:52:54 PM4/25/13
to cu...@googlegroups.com

On Friday, 26 April 2013 at 01:50, Mike Howells wrote:



On Friday, 26 April 2013 10:22:19 UTC+10, Aslak Hellesøy wrote:

On Friday, 26 April 2013 at 00:35, Mike Howells wrote:

How do you set up a POM to get Cucumber-JVM to execute feature tests using Groovy glue code in the test phase?
Can you create an issue on github and request for an example to be added?

Aslak


Note that the Groovy example POM
that's not an example, that's the cucumber-groovy module itself! 
assumes that ${basedir}/bin/cucumber-groovy.jar exists, but Maven doesn't seem to install that when it downloads dependencies.

Mike Howells

unread,
Apr 25, 2013, 9:04:07 PM4/25/13
to cu...@googlegroups.com


On Friday, 26 April 2013 10:52:54 UTC+10, Aslak Hellesøy wrote:

On Friday, 26 April 2013 at 01:50, Mike Howells wrote:



On Friday, 26 April 2013 10:22:19 UTC+10, Aslak Hellesøy wrote:

On Friday, 26 April 2013 at 00:35, Mike Howells wrote:

How do you set up a POM to get Cucumber-JVM to execute feature tests using Groovy glue code in the test phase?
Can you create an issue on github and request for an example to be added?

Aslak


Note that the Groovy example POM
that's not an example, that's the cucumber-groovy module itself! 


Okay, by "example" I meant a POM that at least contains some clues as to how to execute Groovy-based Cucumber tests.  ;o)

Mike Howells

unread,
Apr 28, 2013, 8:49:22 PM4/28/13
to cu...@googlegroups.com
In the meantime, I don't understand why the surefire plugin is failing to find and execute the JUnit wrapper class. 

It has the right kind of class name (**/Test*) and the right annotations, but even if I explicitly select the wrapper class Maven says there are no tests to run:

    > mvn -Dtest=TestFeatures
    [INFO] Scanning for projects...
    :::

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running com.example.mytesting.TestFeatures
    Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@4c397cea
    Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.52 sec

    Results :

    Tests run: 0, Failures: 0, Errors: 0, Skipped: 0


Mike Howells

unread,
Apr 29, 2013, 1:13:48 AM4/29/13
to cu...@googlegroups.com
Turns out that one of my dependencies has a dependency on testNG. If I explicitly exclude testNG in my POM then Surefire uses plain JUnit 4 and does find all the tests, including the Cucumber wrapper.

    <exclusion>
        <!-- exclude testNG otherwise Surefire doesn't find TestFeatures -->
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
    </exclusion>
Reply all
Reply to author
Forward
0 new messages