Re: Help needed: maven-surefire-plugin is skipping/not finding tests

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Help needed: maven-surefire-plugin is skipping/not finding tests

Tibor Digana
There is zero tests to run because you have globally specified a "groups"
but there are no tests annotated with such group in your project
hadoop-hdfs.
Try to come over this issue by specifying empty groups in this child.
<groups combine.self="override"></groups>

Let's go back to your three questions.
1. The pluginManagement should be in parent and children should not
specify/override plugin version, unless necessary.
2. You can use the latest version 2.22.0 but groups is old feature
available in 2.21.0 or 2.20.0 too and earlier.
3. Fix for groups is on your side, since you specify groups in parent POM
it means all children should undergo the same principle and all tests
should be annotated with one group at least. In your case when you still
have test which are not annotated with groups is to make the "groups"
config parameter empty. You can run the Maven in debug mode (mvn -X ...)
and you can see how the parameter is set in this plugin.

T

On Thu, Jul 26, 2018 at 6:15 PM, Jun Huang <[hidden email]>
wrote:

> Hi,
>
> Recently in our hadoop project, we added maven-surefire-plugin for running
> unit tests by categories.
>
> in hadoop root pom.xml:
>
>       <dependency>
>         <groupId>junit</groupId>
>         <artifactId>junit</artifactId>
>         <version>4.11</version>
>       </dependency>
> :
> :
>
> <properties>
>     <test.groups>org.apache.hadoop.classification.
> TestJUnitCategory$AllTests</test.groups>
>     <junit.version>4.11</junit.version>
> </properties>
>
>         <plugin>
>           <groupId>org.apache.maven.plugins</groupId>
>           <artifactId>maven-surefire-plugin</artifactId>
>           <version>2.21.0</version>
>           <configuration>
>             <groups>${test.groups}</groups>
>           </configuration>
>         </plugin>
>
>
>     <profile>
>       <id>flakies</id>
>       <properties>
>         <test.groups>org.apache.hadoop.classification.
> TestJUnitCategory$FlakiesTest</test.groups>
>       </properties>
>     </profile>
>     <profile>
>       <id>stables</id>
>       <properties>
>         <test.groups>org.apache.hadoop.classification.
> TestJUnitCategory$StablesTest</test.groups>
>       </properties>
>     </profile>
>     <profile>
>       <id>integrations</id>
>       <properties>
>         <test.groups>org.apache.hadoop.classification.TestJUnitCategory$
> IntegrationsTest</test.groups>
>       </properties>
>     </profile>
>     <profile>
>       <id>none</id>
>       <properties>
>         <test.groups>!org.apache.hadoop.classification.
> TestJUnitCategory$AllTest</test.groups>
>       </properties>
>     </profile>
>   </profiles>
>
> Invoking tests by category works fine: mvn -P integrations. However, our
> old fashioned unit test execution got skipped by this maven-surefire-plugin:
>
> 13:16:35 [INFO] --- maven-antrun-plugin:1.7:run (create-log-dir) @
> hadoop-hdfs ---
> 13:16:35 [INFO] Executing tasks
> 13:16:35
> 13:16:35 main:
> 13:16:35    [delete] Deleting directory /tmp/tmp.o7flMN8505/src/
> ghuang/ghuang/hadoop-hdfs-project/hadoop-hdfs/target/test/data
> 13:16:35     [mkdir] Created dir: /tmp/tmp.o7flMN8505/src/
> ghuang/ghuang/hadoop-hdfs-project/hadoop-hdfs/target/test/data
> 13:16:35      [copy] Copying 16 files to /tmp/tmp.o7flMN8505/src/
> ghuang/ghuang/hadoop-hdfs-project/hadoop-hdfs/target/test-classes/webapps
> 13:16:35 [INFO] Executed tasks
> 13:16:35 [INFO]
> 13:16:35 [INFO] --- maven-compiler-plugin:3.1:testCompile
> (default-testCompile) @ hadoop-hdfs ---
> 13:16:35 [INFO] Nothing to compile - all classes are up to date
> 13:16:35 [INFO]
> 13:16:35 [INFO] --- maven-surefire-plugin:2.20:test (default-test) @
> hadoop-hdfs ---
> 13:16:35 [INFO] Surefire report directory: /tmp/tmp.o7flMN8505/src/
> ghuang/ghuang/hadoop-hdfs-project/hadoop-hdfs/target/surefire-reports
> 13:16:35 [INFO] parallel='none', perCoreThreadCount=true, threadCount=0,
> useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0,
> threadCountMethods=0, parallelOptimized=true
> 13:16:35 [INFO]
> 13:16:35 [INFO] -------------------------------------------------------
> 13:16:35 [INFO]  T E S T S
> 13:16:35 [INFO] -------------------------------------------------------
> 13:26:01 [INFO]
> 13:26:01 [INFO] Results:
> 13:26:01 [INFO]
> 13:26:01 [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
> 13:26:01 [INFO]
> 13:26:01 [INFO]
> 13:26:01 [INFO] --- maven-antrun-plugin:1.7:run (hdfs-test-bats-driver) @
> hadoop-hdfs ---
>
> I also verified that by removing surefire-plugin block in root pom.xml
> file will make these tests executing again as usual. So I have some
> questions here:
>
> 1. I saw the reported surefire-plugin version was 2.20 while I was
> defining 2.21 in my change. This is because it gets overwritten by the
> parent pom. So how do I make it use my customized version.
>
> 2. Is the version 2.21 the right version for this? I saw some post
> indicated version 2.21 might have some bug?
>
> 3. What is the fix for this issue?
>
>
> Many thanks,
> George
>
> See attached pom.xml file.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>