Search code examples
androidmavencucumberfunctional-testing

How to integrate cucumber into android-maven test project?


I would like to integrate cucumber into an android-test project which uses maven as a build system. The test-project is separated from the main project, and it only contains the robotium-based functional tests. I followed this tutorial and the examples here, but during the testing phase I got: 0 tests found.. Any ideas? Thanks in advance.


Solution

  • Erik. I don't recommend this links, but please mind that you have to make all of cucumber dependency to compile scope. Use Junit4 which going to give duplicationDependency, but use this command to build:

    build command:    mvn clean install  -Dandroid.extractDuplicates=true
    

    part of pom.xml

    <dependency>
     <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>compile</scope>
        </dependency>
    
        <!-- cucumber -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-android</artifactId>
            <version>1.2.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-html</artifactId>
            <version>0.2.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>1.1.5</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    

    part of AndroidManifest.xml content (application's id, what you want to be tested com.myproject.android):

       <instrumentation
            android:name="cucumber.api.android.CucumberInstrumentation"
            android:targetPackage="com.myproject.android" />