mardi 26 janvier 2021

Maven skips tests,

I have Java 8 maven project which has couple for modules, each module has own pom.xml and there is one pom.xml in main project folder. Problem is that mvn test skips tests. I've run mvn test -X which provided me under maven-surefire-plugin:3.0.0-M3:test label with

[DEBUG]   (s) skip = true
[DEBUG]   (s) skipTests = true

After help from other stackoveflow posts I've added

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
     <skipTests>false</skipTests>
     <skip>false</skip>
  </configuration>
</plugin>

which solved problem under that label, but also under section maven-compiler-plugin:3.8.0:testCompile there is still:

[DEBUG]   (f) skip = true

Tests still aren't being executed and I cannot find anything usefull. Below is pom.xml of one of submodules and main pom.xml, I have ommited including internal dependencies.

main pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>pl.com.REDACTED</groupId>
        <artifactId>bom</artifactId>
        <version>5.6.0</version>
    </parent>

    <artifactId></artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>



    <properties>

     

        <!-- Logging -->
        <log4j.version>1.2.17</log4j.version>
        <slf4j-log4j12.version>1.7.12</slf4j-log4j12.version>
        <guava.version>18.0</guava.version>

        <!-- Arquillian -->
        <arquillian.version>1.1.12.Final</arquillian.version>
        <arquillian_persistence.version>1.0.0.Alpha7</arquillian_persistence.version>
        <arq.version-glassfish-remote>1.0.0.Final</arq.version-glassfish-remote>
        <shrinkwrap-resolver-depchain.version>2.2.5</shrinkwrap-resolver-depchain.version>

        <!-- Lombok -->
        <lombok-maven.version>1.16.16.0</lombok-maven.version>
        <lombok.version>1.18.16</lombok.version>

        <!-- Jackson -->
        <jackson.version>2.25.1</jackson.version>

        <poi.version>3.16</poi.version>
        <maven-failsafe-plugin.version>2.22.1</maven-failsafe-plugin.version>
        <TransferManager-Internal-Common.version>1.1.0-SNAPSHOT</TransferManager-Internal-Common.version>
        <gson.version>2.8.6</gson.version>
    </properties>

    <build>
        <finalName>REDACTED</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven-failsafe-plugin.version}</version>
                </plugin>

                <plugin>
                    <groupId>org.projectlombok</groupId>
                    <artifactId>lombok-maven</artifactId>
                    <version>${lombok-maven.version}</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <skip>false</skip>
                        <skipTests>false</skipTests>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

    </build>

    <dependencyManagement>
        <dependencies>
     
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
                <version>${poi.version}</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-json-jackson</artifactId>
                <version>${jackson.version}</version>
            </dependency>

            <dependency>
                <groupId>org.glassfish.jersey.core</groupId>
                <artifactId>jersey-client</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>${gson.version}</version>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <dependencies>

        <!-- JAVAEE 7 API -->
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j-log4j12.version}</version>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>

    </dependencies>

</project>

submodule pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>REDACTED</artifactId>
        <groupId>REDACTED</groupId>
        <version>1.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>REDACTED</artifactId>

    <build>
        <resources>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>jasper/**/*</exclude>
                    <exclude>fonts/**/*</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources/fonts</directory>
                <targetPath>fonts/</targetPath>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>false</skipTests>
                    <skip>false</skip>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jasperreports-maven-plugin</artifactId>
                <version>1.0-beta-2</version>
                <configuration>
                    <sourceDirectory>src/main/resources/report</sourceDirectory>
                    <outputDirectory>${project.build.directory}/classes/report</outputDirectory>
                </configuration>
               <executions>
                    <execution>
                        <goals>
                            <goal>compile-reports</goal>
                        </goals>
                        <phase>compile</phase>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.jasperreports</groupId>
                        <artifactId>jasperreports</artifactId>
                        <version>4.5.1</version>
                        <exclusions>
                            <exclusion>
                                <artifactId>jdtcore</artifactId>
                                <groupId>eclipse</groupId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                    <dependency>
                        <groupId>xerces</groupId>
                        <artifactId>xercesImpl</artifactId>
                        <version>2.8.1</version>
                    </dependency>
                    <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <version>1.2.14</version>
                    </dependency>
                    <dependency>
                        <groupId>xml-apis</groupId>
                        <artifactId>xml-apis</artifactId>
                        <version>1.4.01</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <profiles>

        <profile>
            <id>REDACTED</id>
            <build>
                <resources>
                    <resource>
                        <filtering>true</filtering>
                        <directory>src/main/resources</directory>
                        <excludes>
                            <exclude>jasper/**/*</exclude>
                            <exclude>fonts/**/*</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>src/main/resources/fonts</directory>
                        <targetPath>fonts/</targetPath>
                    </resource>
                </resources>

                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/target/classes/META-INF</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/resources/META-INF/REDACTED</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.0.2</version>
                        <configuration>
                            <excludes>
                                Buch of excluded locations for finders, not related to tests
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>REDACTED</id>
            <build>
                <resources>
                    <resource>
                        <filtering>true</filtering>
                        <directory>src/main/resources</directory>
                        <excludes>
                            <exclude>jasper/**/*</exclude>
                            <exclude>fonts/**/*</exclude>
                        </excludes>
                    </resource>
                    <resource>
                        <directory>src/main/resources/fonts</directory>
                        <targetPath>fonts/</targetPath>
                    </resource>
                </resources>

                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/target/classes/META-INF</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/resources/META-INF/REDACTED2</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.0.2</version>
                        <configuration>
                            <excludes>
                                Buch of excluded locations for finders, not related to tests
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj-core.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Arquillian junit -->
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <version>${arquillian.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-container-spi</artifactId>
            <version>${arquillian.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Arquillian persistence -->
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-persistence-api</artifactId>
            <version>${arquillian_persistence.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Glassfish Remote -->
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-glassfish-remote-3.1</artifactId>
            <version>${arq.version-glassfish-remote}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-depchain</artifactId>
            <version>${shrinkwrap-resolver-depchain.version}</version>
            <scope>test</scope>
            <type>pom</type>
        </dependency>

        <!-- HIBERNATE -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-envers</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Jasper Reports -->
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fatboyindustrial.gson-javatime-serialisers</groupId>
            <artifactId>gson-javatime-serialisers</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.2</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

</project>

Aucun commentaire:

Enregistrer un commentaire