0
我想从命令行编译并在Groovy中运行单元测试。项目中的包装结构并不遵循命名惯例 - 这是我现在不能改变的东西。这些类组织为:Maven无法解析org.junit.test
src/abc/def/SomeClass.groovy
src/abc/tests/def/TestSomeClass.groovy
当我运行mvn test
,该消息是:
无法解决类org.junit.Test
和
无法resovle类org.junit.Assert
src/abc/tests/def/TestSomeClass.groovy
。
我POM是:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>my-project</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<configuration>
<sources>
<source>
<directory>src</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/Test*.groovy</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
我重构包/目录,让他们按照惯例 '的src /测试/常规/ ABC/DEF /'。 而我仍然收到相同的信息 - 无法解析org.junit.Test和org.junit.Assert。 如果我禁用 '测试 ' 编译成功(gmavenplus火的testCompile消息 - 编译XY文件),但没有测试运行。 –