3

I have a pom.xml in that I have not explicitly mentioned to skip test cases. When when I run it using mvn clean install, tests are being skipped.

[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ raah-delta-committer ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ raah-delta-committer ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ raah-delta-committer ---
[INFO] Tests are skipped.

When ran with command -X

[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ raah-delta-committer ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-resources-plugin:2.6:testResources from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-resources-plugin:2.6, parent: sun.misc.Launcher$AppClassLoader@5c647e05]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-resources-plugin:2.6:testResources' with basic configurator -->
[DEBUG]   (f) buildFilters = []
[DEBUG]   (s) delimiters = [@]
[DEBUG]   (f) encoding = UTF-8
[DEBUG]   (f) escapeWindowsPaths = true
[DEBUG]   (s) includeEmptyDirs = false
[DEBUG]   (s) outputDirectory = D:\projects\test\raah-cpp-integration\raah-delta-committer\target\test-classes
[DEBUG]   (s) overwrite = false
[DEBUG]   (f) project = MavenProject: com.tomtom.raah:raah-delta-committer:0.0.1-SNAPSHOT @ D:\projects\test\raah-cpp-integration\raah-delta-committer\pom.xml
[DEBUG]   (s) resources = [Resource {targetPath: null, filtering: false, FileSet {directory: D:\projects\test\raah-cpp-integration\raah-delta-committer\src\test\resources, PatternSet [includes: {}, excludes: {}]}}]
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@69c6161d
[DEBUG]   (f) skip = true
[DEBUG]   (f) supportMultiLineFiltering = false
[DEBUG]   (f) useBuildFilters = true
[DEBUG]   (s) useDefaultDelimiters = false
[DEBUG] -- end configuration --
[INFO] Not copying test resources

My parent POM profile is

<profiles>
    <profile>
        <id>sonar-coverage</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <pluginManagement>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.7.2.201409121644</version>
                    </plugin>
                </plugins>
            </pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <configuration>
                        <append>true</append>
                    </configuration>
                    <executions>
                        <execution>
                            <id>agent-for-ut</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>agent-for-it</id>
                            <goals>
                                <goal>prepare-agent-integration</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>jacoco-site</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

My parent build is

<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-scm-plugin</artifactId>
                    <version>1.9.4</version>
                    <configuration>
                        <tag>${project.artifactId}-${project.version}</tag>
                        <basedir>${project.basedir}</basedir>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

My child build is

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
Shruti Gupta
  • 310
  • 4
  • 9
  • Have you configure surefire plugin in pom.xml? – Afgan Apr 02 '18 at 06:47
  • No.. we have not used surefire plugin – Shruti Gupta Apr 02 '18 at 06:51
  • Please add this is your parent pom.xml -> org.apache.maven.plugins maven-failsafe-plugin 2.21.0 false – Afgan Apr 02 '18 at 06:58
  • Try running with -X to get debug output, then look at the surefire plugin's configuration. I would also suspect a plugin inheritance problem. Is the surefire plugin configured in a parent POM? – Afgan Apr 02 '18 at 07:10
  • Please show the full pom file and check the parent as well... – khmarbaise Apr 02 '18 at 08:10
  • @khmarbaise please look on log, there is [DEBUG] (f) skip = true, (f) -> what it means ? I go through this [link](https://stackoverflow.com/questions/17547931/maven-is-automatically-skipping-tests). Is this make any difference ? – Afgan Apr 02 '18 at 08:37
  • I don't know cause I don't know your pom files...there must be configured something like this...which is very strange that someone is skipping resources plugin..Does not make sense... – khmarbaise Apr 02 '18 at 08:39
  • @khmarbaise sorry i have put wrong link please look on [this](https://stackoverflow.com/questions/2022154/maven-debugging-output-what-does-f-mean) for [DEBUG] (f) skip = true, (f) -> what it means ? – Afgan Apr 02 '18 at 08:44
  • Obviously it's skipped...the question is where is this coming from ? But without the full pom files etc. it's impossible to say... – khmarbaise Apr 02 '18 at 08:56
  • add your current pom + parent pom to the question. – eis Apr 02 '18 at 09:07
  • please also don't replace code with images. I have reverted that change. – eis Apr 02 '18 at 09:08
  • 1
    not just the build section - the entire pom is relevant. – eis Apr 02 '18 at 09:48
  • I assume you have somewhere changed the default directories using something like `...` ...or `-DskipTests` on console added ? – khmarbaise Apr 02 '18 at 12:28

2 Answers2

6

I m pretty sure that some where in your pom.xml(configuration) you are skipping test.

Please follow the following step to identify the issue -

1 - if you are using eclipse IDE them open your effective pom.xml(resolved pom for your parent project), and search

a- maven.skip.test or

b- skip.test

I hope you could be able to find out one of this, if you find then,

2- search that in your all parent hierarchy pom.xml's.

if its not fount in parent pom.xml and then,

3- search that in maven setting.xml where some time global properties are set.

Afgan
  • 1,022
  • 10
  • 32
0

It's possible that your parent pom.xml file contains surefire configuration which skips test phase execution, i.e. something like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <skip>true</skip>
        <testFailureIgnore>true</testFailureIgnore>
    </configuration>
</plugin>

All you need to do is to overwrite this configuration by changing your child pom.xml file:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${version}</version>
    <configuration>
        <skip>false</skip>
    </configuration>
</plugin>
ruslangm
  • 674
  • 7
  • 19