gmaven 未找到测试

发布于 2024-09-26 08:40:39 字数 4332 浏览 7 评论 0原文

嗨,我遇到了一些错误 我在 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"
 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>

我的 groovy 文件位于 src/groovy 和 test/groovy

我做错了什么?

顺便说一句,当我添加此配置时,我收到编译错误:

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

将其添加到 groovy-maven-plugin 时编译错误的文件

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

Hi i m running into some error
I have a really small project in groovy.
I want to use maven.
I was able to compile my files, source and test(i have my .class in the target folder). But no test are executed.
here is my pom file.

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

My groovy files are in src/groovy and test/groovy

What i'm dooing wrong?

BTW, I get compilation errors when I add this configuration:

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

compile my file with erro when adding this to the groovy-maven-plugin

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独留℉清风醉 2024-10-03 08:40:39

一方面,您使用的是过时版本的 GMaven。

该插件已移至 Group 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 找到您测试班。

请参阅此页面以供参考:使用 GMaven 构建 Groovy 项目

更新:

如果我定义要运行的测试,它就会运行。但
仅使用 mvn clean 测试,测试是
已编译,但未执行

这听起来好像您没有遵循测试类的命名约定。

请参阅本页的第一部分: 测试的包含和排除

Well for one thing you are using an outdated version of GMaven.

The plugin has moved to the Group Id org.codehaus.gmaven and the current version is 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>

Also, you probably need to keep the stub goals active for JUnit to find you test classes.

See this page for reference: Buildung Groovy Projects with GMaven

Update:

If i define a test to run, it run. but
with just mvn clean test, the test are
compiled, but not executed

This sounds like you're not following the naming conventions for test classes.

See the first section of this page: Inclusions and Exclusions of Tests

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文