0

I'm creating a testing framework with Java 11 and Maven, and I have build two different runners for separate tests. I want to run only one profile but it keeps running both of them. Here are my profiles:

<profiles>
        <profile>
            <id>smoke</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.21.0</version>
                        <executions>
                            <execution>
                                <id>smoke</id>
                                <configuration>
                                    <includes>
                                        <include>**/SmokeRunnerTest.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>functional</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.21.0</version>
                        <executions>
                            <execution>
                                <id>functional</id>
                                <configuration>
                                    <includes>
                                        <include>**/FunctionalRunnerTest.java</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
Didier L
  • 18,905
  • 10
  • 61
  • 103
  • What are you using to run maven? – Didier L Feb 14 '22 at 11:01
  • Does this answer your question? [Maven: How do I activate a profile from command line?](https://stackoverflow.com/questions/30927064/maven-how-do-i-activate-a-profile-from-command-line) – Didier L Feb 14 '22 at 11:03
  • terminal command mvn clean install -P functional, but it runs both of them after one another – SMTHNGBD Feb 14 '22 at 11:05
  • 1
    Maybe the failsafe plugin ends up including both classes? Try excluding **. – alamar Feb 14 '22 at 11:07
  • Why are those things named like a unit test? `*Test.java` instead of an `*IT.java`based on the usage of the failsafe plugin. – khmarbaise Feb 14 '22 at 12:10

1 Answers1

1

You can put

<activation>
  <activeByDefault>false</activeByDefault>
</activation>

into profiles' definition to avoid unneeded profile activation.

alamar
  • 18,729
  • 4
  • 64
  • 97
  • Nope, didn't work. Still running two profiles, I used mvn clean install -P functional – SMTHNGBD Feb 14 '22 at 11:40
  • 1
    I think your problem is not with profiles it's that you need to exclude all classes from failsafe plugin before including the required one. – alamar Feb 14 '22 at 12:04
  • @alamar, Are you able to answer this question by any chance? https://stackoverflow.com/questions/71104529/can-maven-run-both-cucumber-junit-and-testng-runners-together – The man Feb 14 '22 at 15:38