Unit testing g未找到任何测试
嗨,我遇到了一些错误 我在groovy中有一个非常小的项目。 我想用maven。 我能够编译我的文件、源代码和测试(我的.class在目标文件夹中)。但没有执行任何测试。 这是我的pom文件Unit testing g未找到任何测试,unit-testing,maven-2,groovy,gmaven-plugin,Unit Testing,Maven 2,Groovy,Gmaven Plugin,嗨,我遇到了一些错误 我在groovy中有一个非常小的项目。 我想用maven。 我能够编译我的文件、源代码和测试(我的.class在目标文件夹中)。但没有执行任何测试。 这是我的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"
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gmedia</groupId>
<artifactId>gmedia.api</artifactId>
<name>Gmedia API project</name>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.2.3</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0-rc-5</version>
<executions>
<execution>
<goals>
<!--<goal>generateStubs</goal>-->
<goal>compile</goal>
<!--<goal>generateTestStubs</goal>-->
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<url>http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo</url>
<id>eclipselink</id>
<layout>default</layout>
<name>Repository for library Library[eclipselink]</name>
</repository>
</repositories>
4.0.0
通用媒体
gmedia.api
gmediaapi项目
1.0-快照
罐子
UTF-8
org.codehaus.groovy
groovy all
1.7.1
朱尼特
朱尼特
4.8.2
测试
net.sf.json-lib
json库
2.2.3
jdk15
org.eclipse.persistence
日食
2.0.2
org.eclipse.persistence
javax.persistence
2.0.0
org.codehaus.groovy.maven
gmaven插件
1.0-rc-5
编译
测试编译
org.apache.maven.plugins
maven编译器插件
2.0.2
1.6
1.6
http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo
日食
违约
图书馆存储库[eclipselink]
我的groovy文件位于src/groovy和test/groovy中
我做错了什么
顺便说一句,添加此配置时会出现编译错误:
<configuration>
<sources>
<fileset>
<directory>${pom.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</fileset>
</sources>
</configuration>
${pom.basedir}/src/test/groovy
**/*B.groovy
将此文件添加到groovy maven插件时,请使用erro编译我的文件
<configuration>
<sources>
<fileset>
<directory>${pom.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</fileset>
</sources>
</configuration>
${pom.basedir}/src/test/groovy
**/*B.groovy
首先,您使用的是过时的GMaven版本
该插件已移动到组Idorg.codehaus.gmaven
,当前版本为1.3
:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
org.codehaus.gmaven
更新:
如果我定义了一个要运行的测试,它就会运行。但是
仅使用mvn清洁测试,测试是
已编译,但未执行
这听起来好像您没有遵循测试类的命名约定
请参阅本页的第一节:将此文件添加到groovy maven插件${pom.basedir}/src/test/groovy**/*。groovy不作为注释,编辑问题文本(为您做了这件事)我听从你的建议。但结果是一样的。如果我定义了一个要运行的测试,它就会运行。但是只使用mvn clean测试,测试是编译的,而不是执行的。非常感谢。我没有注意它,因为我从grails带来了这个项目,它使用了模式,测试。这是我的错误。