Maven无法解析org.junit.test
我试图从命令行在Groovy中编译和运行单元测试。项目中的包结构没有遵循命名约定-这是我目前无法更改的。课程安排如下:Maven无法解析org.junit.test,maven,grails,junit,Maven,Grails,Junit,我试图从命令行在Groovy中编译和运行单元测试。项目中的包结构没有遵循命名约定-这是我目前无法更改的。课程安排如下: src/abc/def/SomeClass.groovy src/abc/tests/def/TestSomeClass.groovy 当我运行mvn测试时,消息是: 无法解析类org.junit.Test 及 无法解析类org.junit.Assert 在类src/abc/tests/def/TestSomeClass.groovy中 我的POM是: <?xml v
src/abc/def/SomeClass.groovy
src/abc/tests/def/TestSomeClass.groovy
当我运行mvn测试时
,消息是:
无法解析类org.junit.Test
及
无法解析类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>
4.0.0
org.codehaus.mojo
我的项目
1
org.codehaus.gmavenplus
gmavenplus插件
1.5
src
**/*B.groovy
编译
添加源
addTestSources
测试编译
org.apache.maven.plugins
maven surefire插件
2.18.1
**/Test*.groovy
org.codehaus.groovy
groovy all
2.4.7
朱尼特
朱尼特
4.11
测试
标准Maven目录布局如下:
用于生产:/src/main/groovy/abc/def
对于测试:/src/test/groovy/abc/def
如果你按照这个计划安排你的资源,你应该不会有问题
我对包/目录进行了重构,使它们遵循惯例
src/test/groovy/abc/def/
。我仍然收到同样的消息-无法解析org.junit.Test和org.junit.Assert。如果禁用test`则编译成功(gmavenplus为testCompile-compiled xy文件触发消息),但不运行任何测试。