maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "simon cierniak (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (SUREFIRE-1517) Getting ClassNotFoundException when filtering tests from a dependency jar
Date Fri, 20 Apr 2018 17:57:00 GMT

    [ https://issues.apache.org/jira/browse/SUREFIRE-1517?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16445943#comment-16445943
] 

simon cierniak edited comment on SUREFIRE-1517 at 4/20/18 5:56 PM:
-------------------------------------------------------------------

{color:#333333}I found a workaround by adding "Spec" after the *
 
{color}
{noformat}
mvn test -Dtest=**/package2/*        => throws exception
mvn test -Dtest=**/package2/*Spec    => works{noformat}
{color:#333333}
 
 Simon{color}


was (Author: scierniak):
{color:#333333}I found a workaround by adding "Spec" after the *
 
 mvn test -Dtest=**/package2*/* *   => throws exception
 mvn test -Dtest=**/package2/*Spec    => works
 
 Simon{color}

> 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
>            Priority: Minor
>         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 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.DSpec
> com.bug.package2.subpackage.C1Spec
> com.bug.package2.subpackage.C2Spec
> {noformat}
>  
> +*Commands:*+
> mvn test -Dtest=***/*Spec*            works : execute ASpec, BSpec, CSpec, DSpec,
C1Spec and C2Spec
> mvn test -Dtest=ASpec             works : execute ASpec
> mvn test -Dtest=***/package1/**  works : execute ASpec and 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}
> {color:#ff0000}The tests executed should be CSpec and DSpec{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}
>  
>  I tested also with version 2.20.1 and 2.19.1 and got same errors.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message