1

I was able to run Cucumber-JVM tests using @RunWith & @CucumberOptions tags.But I am unable to execute the tests using Maven. Can somebody point me in the right direction ?

I am trying to use maven sure fire plugin, after scouring the internet.I do think, I am making a mistake, which I dont't know abt.

7
  • 1
    Can you post how your jUnit test classes are annotated? Also, where are your feature files and jUnit test located? Commented Feb 25, 2015 at 0:06
  • The way I have created the test cases are: using the page object model for corresponding user actions and then mapped the action to statements including the assertions.So, I dont have the Junit testcases in the conventionally speaking. the Project Structure : Commented Feb 25, 2015 at 0:13
  • @CargoCult The Project Structure : src -> test. | test -> config | test ->features | test -> steps. The RunCukeTests is in the steps package. Does this help ? Commented Feb 25, 2015 at 0:20
  • Post the code of how you use RunWith & CucumberOptions Commented Feb 25, 2015 at 0:38
  • package steps; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; import org.junit.runner.RunWith; @CucumberOptions(format = {"pretty"}, features = {"."}, monochrome = true) @RunWith(Cucumber.class) public class RunCukeTests { } Commented Feb 25, 2015 at 0:45

2 Answers 2

1

The directory structure is :

 src\test\ 
   --config\
   --resources\ (has the .feature files)
   --steps\  (classes for the steps)

===================maven POM file=======================

http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>Project</groupId>
<artifactId>Project</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <cucumber.options>--format pretty</cucumber.options>
    <testsrc>src/test/</testsrc>
</properties>

<dependencies>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.0</version>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.0</version>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>1.2.0</version>
    </dependency>

    <dependency> <!-- External Dependency -->
        <groupId>ojdbc6</groupId>
        <artifactId>ojdbc6</artifactId>
        <scope>system</scope>
        <version>1.0</version>
        <systemPath>E:\work\test\Project\libs\ojdbc6dms.jar</systemPath>
    </dependency>

    <dependency> <!-- External Dependency -->
        <groupId>sqljdbc</groupId>
        <artifactId>ojdbc6</artifactId>
        <scope>system</scope>
        <version>1.0</version>
        <systemPath>E:\work\test\Project\libs\sqljdbc4.jar</systemPath>
    </dependency>
</dependencies>

<build>
    <testSourceDirectory>${testsrc}</testSourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <parallel>classes</parallel>
                <threadCount>1</threadCount>
                <includes>
                    <include>**/RunCukeTests.java</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
</build>

Sign up to request clarification or add additional context in comments.

1 Comment

why do you use <parallel>classes</parallel> together with <threadCount>1</threadCount>? It is to execute in parallel with one thread running which is the sam as sequential execution
0

Try adding Maven Compiler plugin as well.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.