I am strugging to achieve this: I want to configure a maven project so that it runs different subsets of the cucumber features depending on the selected profile (dev | pro)
For instance, I have a couple of feature files to test web navigation, using tags to specify the environment:
PRO
@pro
Feature: Nav Pro
Scenario: navigate to home
Given access /
Then it should be at the home page
DEV
@dev
Feature: Nav Dev
Scenario: navigate to login and log user correctly
Given access /login
When the user enters xxxx yyyy
Then it should be logged
I created two Test java classes, one for each environment:
COMMON BASE CLASS:
@Test(groups="cucumber")
@CucumberOptions(format = "pretty")
public class AbstractBddTest extends AbstractTestNGCucumberTests {
PRO
@Test(groups="cucumber")
@CucumberOptions(tags={"@pro", "~@dev"})
public class ProTest extends AbstractBddTest{}
DEV
@Test(groups="cucumber")
@CucumberOptions(tags={"@dev", "~@pro"})
public class DevTest extends AbstractBddTest{}
Maven cfg excerpt:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>${test-groups}</groups>
</configuration>
</plugin>
...
<properties>
<test-groups>unit,integration</test-groups>
</properties>
When I run mvn test -Dtest-groups=cucumber
it obviously runs both test clases, and each will test its corresponding tagged feature. How can I select the tag using a profile so that only one of the test classes executes?