I wrote a test where I am importing a class from package com/intel/epgsw/JunitAdapter.groovy
When I try to run the test, I get this error:
[ERROR] Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.5:testCompile (groovy) on project jenkinsfile-test-shared-library: Error occurred while calling a method on a Groovy class from classpath. InvocationTargetException: startup failed:
[ERROR] src/test/groovy/CloneTestSpec.groovy: 3: unable to resolve class src.com.intel.epgsw.JunitAdapter
[ERROR] @ line 3, column 1.
[ERROR] import com.intel.epgsw.JunitAdapter
[ERROR] ^
Test file is present in: src/test/groovy
Class that needs to be imported: com/intel/epgsw/JunitAdapter.groovy
My test file is CloneTestSpec.groovy
Here is the tree :
src
│ ├── com
│ │ └── intel
│ │ ├── epgsw
│ │ │ ├── TestResultEnum.groovy
│ │ │ ├── **JunitAdapter.groovy**
│ │ │
│ └── test
│ ├── com
│ │ └── intel
│ │ └── epgsw
│ ├── epgsw
│ │ └── FooBar98.groovy
│ ├── groovy
│ │ ├── **CloneTestSpec.groovy**
This is a section of my pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<configuration>
<testSourceDirectory>src/test/groovy</testSourceDirectory>
<includes>
<include>**/*Spec.java</include>
<include>**/*Spec.class</include>
<include>**/*Spec</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>${groovy.gmaven.pluginVersion}</version>
<executions>
<execution>
<id>groovy</id>
<goals>
<goal>addTestSources</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>
<directory>src</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</source>
</sources>
<testSources>
<testSource>
<directory>src/test/groovy/com/intel/epgsw</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
</plugin>
</plugins>