Tagged: profile

profiling different implementations for testing


I’m writing a small library which used JAX-RS API.

<dependency>
  <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0.1</version>
    <scope>provided</scope>
</dependency>

Profiles can help for testing the code against each implementation.

<profile>
  <id>jersey</id>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <dependencies>
    <dependency>
      <groupId>org.glassfish.jersey.core</groupId>
      <artifactId>jersey-client</artifactId>
      <version>2.23.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</profile>    
<profile>
  <id>cxf</id>
  <dependencies>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-rs-client</artifactId>
      <version>3.1.6</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</profile>    
<profile>
  <id>resteasy</id>
  <dependencies>
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-client</artifactId>
      <version>3.0.17.Final</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</profile>

Test against each implementation like this.

$ mvn -Pjersey verify
$ mvn -Pcxf verify
$ mvn -Presteasy verify
Advertisements

profiling maven tests


I have a very special case of profiling test cases.

ūnus

Note that following example doesn’t work!

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>target13</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skipTests>false</skipTests>
              <includes>
                <include>com/googlecode/jinahya/test/Target13Test.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile> 
    <profile>
      <id>target14</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skipTests>false</skipTest>
              <includes>
                <include>com/googlecode/jinahya/test/Target14Test.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

Simply failed. I found an issue which is marked as Fixed but this documentation update is what we should read.

duo

There is a work-around for this problem.

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/*.java</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>target13</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>NONE</exclude>
              </excludes>
              <includes>
                <include>com/googlecode/jinahya/test/Target13Test.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile> 
    <profile>
      <id>target14</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>NONE</exclude>
              </excludes>
              <includes>
                <include>com/googlecode/jinahya/test/Target14Test.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

It works.

trēs

This is how I solved my problem.

<project>
  <properties>
    <skipTests>true</skipTests>
  </properties>
  <build>
    <plugins>
      <!--
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration/>
      </plugin>
      -->
    </plugins>
  </build>
  <profiles>
    <properties>
      <skipTests>false</skipTests>
    </properties>
    <profile>
      <id>target13</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <includes>
                <include>com/googlecode/jinahya/test/Target13Test.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile> 
    <profile>
      <id>target14</id>
      <properties>
        <skipTests>false</skipTests>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <includes>
                <include>com/googlecode/jinahya/test/Target14Test.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>