Question

The testing for this project is super heavy and to keep development going, I want to skip by default. However, they will be run on a regular basis for a given environment if specified. Here is what I have so far.

<project>
  <properties> 
    <skip.tests>true</skip.tests>
  </properties>
  <profiles>
    <profile>
      <id>test.dev</id>
      <properties>
        <env>dev</env>
        <test.info>123456789</test.info>
        <skip.tests>false</skip.tests>
      </properties>
    </profile>
    <profile>
      <id>test.int</id>
      <properties>
        <env>int</env>
        <test.info>987654321</test.info>
        <skip.tests>false</skip.tests>
      </properties>
    </profile>
    <profile>
      <id>skip.tests</id>
      <activation>
        <property>
          <name>skip.tests</name>
          <value>true</value>
        </property>
      </activation>
      <properties>
        <maven.test.skip>true</maven.test.skip>
      </properties>
    </profile>
  </profiles>
</project>

When I run it with the profile, it looks good.

$ mvn help:active-profiles -Ptest.dev
The following profiles are active:
- test.dev

And without args:

$ mvn help:active-profiles
The following profiles are active:

What I want it to say is:

$ mvn help:active-profiles
The following profiles are active:
- skip.tests
Was it helpful?

Solution

You should add something like this to your profile definition:

<profiles>
  <profile>
    <id>profile-1</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    ...
  </profile>
</profiles>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top