2010-10-05 113 views
2

嗨,我米跑到一些錯誤 我有一個非常小的項目在groovy。 我想使用maven。 我能夠編譯我的文件,源代碼和測試(我的目標文件夾中有我的.class文件)。但是沒有執行測試。 這是我的pom文件。gmaven沒有測試發現

<?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> 

我的常規文件中的src/Groovy和測試/常規

什麼,我dooing錯了嗎?

順便說一句,我得到的編譯錯誤,當我加入這個配置:

<configuration> 
    <sources> 
     <fileset> 
      <directory>${pom.basedir}/src/test/groovy</directory> 
      <includes> 
       <include>**/*.groovy</include> 
      </includes> 
     </fileset> 
    </sources> 
</configuration> 

編譯我的文件,這增加了Groovy的Maven的插件

<configuration> 
      <sources> 
      <fileset> 
       <directory>${pom.basedir}/src/test/groovy</directory> 
       <includes> 
       <include>**/*.groovy</include> 
       </includes> 
      </fileset> 
      </sources> 
     </configuration> 
+0

編譯我文件與此增加了Groovy的行家-插件 <結構> $ {pom.basedir}/SRC時ERRO /測試/常規 **/*。常規 benzen 2010-10-06 11:52:42

+0

不作爲評論,編輯問題文本(爲你做的) – 2010-10-06 12:24:26

回答

3

好時埃羅有一件事你正在使用過時的GMaven版本。

該插件已經移動到組ID org.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> 

此外,你可能需要保持短線目標活躍JUnit來找到你的測試類。

參考見本頁面:Buildung Groovy Projects with GMaven

更新:

如果我確定要運行的測試,它運行。但 只有MVN乾淨的測試,測試的 編譯,但不執行

這聽起來像是你不遵循測試類的命名約定。

查看當前頁的第一部分:Inclusions and Exclusions of Tests

+0

我遵循你的建議。但結果是一樣的。如果我定義一個測試運行,它會運行。但只是mvn clean test,測試會被編譯,但不會被執行。 – benzen 2010-10-06 12:20:30

+0

@BenZen查看我的更新回答 – 2010-10-06 12:28:34

+0

非常感謝。 我沒有注意到它,因爲我從grails帶來這個項目,使用模式,測試。 S是我的錯誤。 – benzen 2010-10-06 13:47:01

相關問題