simon cierniak created SUREFIRE-1517:
----------------------------------------
Summary: Getting ClassNotFoundException when filtering tests from
a dependency jar
Key: SUREFIRE-1517
URL: https://issues.apache.org/jira/browse/SUREFIRE-1517
Project: Maven Surefire
Issue Type: Bug
Components: Maven Surefire Plugin
Affects Versions: 2.21.0
Environment: Windows
Reporter: simon cierniak
Attachments: 2018-04-19T12-07-18_153-jvmRun1.dump
The issue happens only when I am using tests from a test jar (using option
dependenciesToScan) and when tests are not into a final package meaning not
having sub-package. FYI, I am executing Spock tests.
To create my test jar, I followed doc
[https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html]
*+Structure+*
{noformat}
com.bug.package1.ASpec
com.bug.package1.BSpec
com.bug.package2.CSpec
com.bug.package2.subpackage.C1Spec
com.bug.package2.subpackage.C2Spec
{noformat}
+*Commands:*+
mvn test -Dtest=**/Test* works : execute ASpec, BSpec, CSpec, C1Spec
and C2Spec
mvn test -Dtest=ASpec works : execute ASpec
mvn test -Dtest=**/package1/* works : execute ASpecand BSpec
mvn test -Dtest=C1Spec works : execute C1Spec
mvn test -Dtest=**/package2/subpackage/* works : execute C1Spec and C2Spec
mvn test -Dtest=CSpec works : execute CSpec
{color:#FF0000}mvn test -Dtest=**/package2/* fails with error:
RuntimeException: Unable to create test class 'com.bug.package2.subpackage.'
... caused by: java.lang.ClassNotFoundException:
com.bug.package2.subpackage.{color}
same error when filtering by com/bug/**/*
+*Pom.xml*+
{noformat}
<?xml version="1.0"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bug</groupId>
<artifactId>demo-execution</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test Bug</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<groovy.version>2.4.5</groovy.version>
<spock.version>1.0-groovy-2.4</spock.version>
<skipTests>false</skipTests>
<SpockTests>**/*Spec.java</SpockTests>
<server.url/>
<junit.groups/>
<junit.excludedGroups/>
<junit.version>4.11</junit.version>
<geb.version>1.1.1</geb.version>
<surefire.version>2.21.0</surefire.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${surefire.version}</version>
</dependency>
</dependencies>
<configuration>
<skip>${skipTests}</skip>
<testFailureIgnore>true</testFailureIgnore>
<failIfNoTests>false</failIfNoTests>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<printSummary>true</printSummary>
<dependenciesToScan>
<dependency>com.bug:demo-tests</dependency>
</dependenciesToScan>
<includes>
<!-- Include for Geb/Spock tests -->
<include>${SpockTests}</include>
</includes>
<!-- IncludeExclude JUnit categories -->
<!-- https://github.com/junit-team/junit4/wiki/Categories
-->
<groups>${junit.groups}</groups>
<excludedGroups>${junit.excludedGroups}</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.bug</groupId>
<artifactId>demo-tests</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
{noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)