Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant get certain feature file tags to run through TeamCity

I have various Cucumber feature files, each with multiple scenarios. Each feature file is for a different component of the system.

I have various runners, one for each of the components and therefore one for each feature file.

Below is some of my project structure where you can see the runners which are the ones which contain _Run_AllTest.java and my features in the Resources folder.

Test
├───java
│   │
│   ├───stepdefs
│   │   ├───MOPStepDefs
│   │   │       ADAWA_Run_AllTest.java
│   │   │       DPL_Run_AllTest.java
│   │   │       MOPStepDefs.java
│   │   │       MOP_Run_AllTest.java
│   │   │
│   │   ├───MOSStepDefs
│   │   │       MOSStepDefs.java
│   │   │       MOS_Run_AllTest.java
│   │   │       PAR_Run_AllTest.java
│   │   │       RenewalApproachingPAR_Run_AllTest.java
│   │   │
│   │   ├───OAStepDefs
│   │   │       OAStepDefs.java
│   │   │       OA_Run_AllTest.java
│   │   │
│   │   └───TPOSStepDefs
│   │           TPOStepDefs.java
│   │           TPOS_Run_AllTest.java
│   │
│   └───Testconfig
│           TestMDABDDConfig.java
│
└───Resources
    ├───MOP Features
    │       ADAWADentalOnlinePayments.feature
    │       DPLDentalOnlinePayments.feature
    │       MemberOnlinePayments.feature
    │
    ├───MOS Features
    │       MemberOnlineService.feature
    │       PolicyAmendRequest.feature
    │       RenewalApproachingPAR.feature
    │
    ├───Online Apps Features
    │       OnlineApplications.feature
    │
    └───TPOS Features
            AllTPOS.feature

To give an example of my tags I'm using, AllTPOS.feature will contain a tag of @AutomatedTPOS on the features I have automated. And there are some with a tag of @Manual. My runner for this feature looks like this:

package stepdefs.TPOSStepDefs;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {
                "html:C:\\Projects\\BDD\\Online Framework\\Reporting\\TPOS Features",
                "pretty"
        },
        features = "src\\test\\Resources\\TPOS Features\\AllTPOS.feature",
        tags = {"~@Manual"}
)


public class TPOS_Run_AllTest {
}

I have included the following in my .pom file where I state to include all my runner files i.e **/*_Run_All*.java

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.0</version>
        <configuration>
            <testSourceDirectory>\src\test\java\</testSourceDirectory>
            <!--<testClassesDirectory>C:/TeamCity/buildAgent2nd/work/classes/</testClassesDirectory>-->
             <includes>
                <include>**/*_Run_All*.java</include>
            </includes>
            <!-- <excludes> <exclude>**/*RunCukesTest.java</exclude> </excludes> -->
        </configuration>
    </plugin>

If I were to run a maven command through command line such as mvn clean test -Dcucumber.options="--tags @AutomatedTPOS" then everything seems to work as expected and only my features with the @AutomatedTPOS tag will run.

So my problem is when we try this through TeamCity. The CI Developer has added JVM command line parameters of -Dmaven.multiModuleProjectDirectory="%mavenhome%" "-Dcucumber.options=--tags @AutomatedTPOS" into TeamCity but when we run from TeamCity it will run every single feature, not just the @AutomatedTPOS ones which we were hoping for.

What am I doing wrong to not see @AutomatedTPOS features only running when we run from TeamCity?

Edit1: If I remove the following from the POM

             <includes>
                <include>**/*_Run_All*.java</include>
            </includes>

And I then run my scenarios through command with mvn clean test -Dcucumber.options="--tags @AutomatedTPOS" then I can see things working as expected i.e. only the @AutomatedTPOS scenarios are being run. But if I then initiate this build through TeamCity, no tests at all run this time. Where as when this line in the POM was present then all scenarios are being run.

And when I look at the build log through TeamCity I can see the comand line contains "-Dcucumber.options=\"--tags @AutomatedTPOS\""

like image 588
Matt Avatar asked Aug 24 '18 06:08

Matt


1 Answers

With help from the CI Developer we found the answer to this.

In TeamCity the parameter for "-Dcucumber.options=--tags @AutomatedTPOS" was supposed to be in the 'Additional Maven command line parameters:' field rather than the 'JVM command line parameters:' field.

I also removed the following from the POM as this has no purpose.

         <includes>
            <include>**/*_Run_All*.java</include>
        </includes>
like image 156
Matt Avatar answered Nov 12 '22 11:11

Matt