Include new test directory maven surefire plugin

前端 未结 2 1871
情歌与酒
情歌与酒 2021-01-14 07:38

Existing Structure : src/test/java --> All java unit tests. This gets picked up easily by Maven surefire plugin. Now, in addition to these java unit test cases, I want to i

相关标签:
2条回答
  • 2021-01-14 08:16

    The following pom is working:

    <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>com.soebes.groovy</groupId>
      <artifactId>first-groovy</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    
      <name>Test Groovy Scripting</name>
    
      <properties>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
    
      <dependencies>
        <dependency>
          <groupId>org.codehaus.gmaven.runtime</groupId>
          <artifactId>gmaven-runtime-2.0</artifactId>
          <version>1.5</version>
        </dependency>
        <dependency>
          <groupId>org.codehaus.groovy</groupId>
          <artifactId>groovy-all</artifactId>
          <version>2.0.0</version>
        </dependency>
        <dependency>
          <groupId>org.testng</groupId>
          <artifactId>testng</artifactId>
          <version>6.8.7</version>
        </dependency>
          <dependency>
            <groupId>org.easytesting</groupId>
            <artifactId>fest-assert</artifactId>
            <version>1.4</version>
          </dependency>
      </dependencies>
    
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
              <compilerId>groovy-eclipse-compiler</compilerId>
              <verbose>true</verbose>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-eclipse-compiler</artifactId>
                <version>2.8.0-01</version>
              </dependency>
              <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-eclipse-batch</artifactId>
                <version>2.0.7-03</version>
              </dependency>
            </dependencies>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
          </plugin>
          <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.5</version>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.gmaven.runtime</groupId>
                <artifactId>gmaven-runtime-2.0</artifactId>
                <version>1.5</version>
              </dependency>
              <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy</artifactId>
                <version>1.8.6</version>
              </dependency>
            </dependencies>
            <configuration>
              <debug>false</debug>
              <verbose>true</verbose>
              <stacktrace>true</stacktrace>
              <defaultScriptExtension>.groovy</defaultScriptExtension>
              <providerSelection>2.0</providerSelection>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>testCompile</goal>
                  <goal>compile</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    
    </project>
    

    You can see a full working example here. This means having groovy tests under src/test/groovy java unit tests under src/test/java.

    0 讨论(0)
  • 2021-01-14 08:17

    Just as Java sources need to be compiled (as done by the maven-compiler-plugin), so do the groovy files. You need to add the gmaven-plugin, see http://docs.codehaus.org/display/GMAVEN/Building+Groovy+Projects#BuildingGroovyProjects-CompilingSources

    UPDATE https://github.com/groovy/GMavenPlus

    0 讨论(0)
提交回复
热议问题