[英]Skip Integration Tests Using Grails Maven Plugin
我正在使用Grails 2.1.0和Maven 2.1.1。 当运行命令mvn clean install
生成EAR文件时,Maven运行单元测试没有任何问题,除了运行两次,然后运行集成测试。 进入集成测试阶段时,将引发错误Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver'
。
通过Grails运行时,单元测试和集成测试全部通过,并且如果我使用-Dmaven.test.skip=true
标志来构建耳朵, -Dmaven.test.skip=true
它会-Dmaven.test.skip=true
构建,并且最终的EAR可以部署到服务器上。
我正在从1.3.7升级此项目,并且该版本在构建时未运行集成测试。 它也只运行了一次单元测试,但是据我读过两次,这是grails-maven插件的一个已知部分。 下面是我正在使用的pom。
<properties>
<grails.version>2.1.0</grails.version>
<slf4j.version>1.6.6</slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-dependencies</artifactId>
<version>${grails.version}</version>
<exclusions>
<exclusion>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</exclusion>
</exclusions>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-plugin-testing</artifactId>
<version>${grails.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>mail</artifactId>
<version>1.0.1</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>jquery</artifactId>
<version>1.7.2</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>resources</artifactId>
<version>1.1.6</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>webxml</artifactId>
<version>1.4.1</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-hibernate</artifactId>
<version>${grails.version}</version>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>hibernate</artifactId>
<version>${grails.version}</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
</dependencies>
<build>
<pluginManagement />
<plugins>
<!-- Disables the Maven surefire plugin for Grails applications, as we have our own test runner -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>plugins</directory>
<includes>
<include>**/*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>${grails.version}</version>
<configuration>
<!-- Whether for Fork a JVM to run Grails commands -->
<fork>false</fork>
</configuration>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>init</goal>
<goal>maven-clean</goal>
<goal>validate</goal>
<goal>config-directories</goal>
<goal>maven-compile</goal>
<goal>maven-test</goal>
<goal>maven-war</goal>
<goal>maven-functional-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我尝试删除了maven-functional-test
目标以及整个执行部分,但是无论哪种方式都遇到相同的问题。 有什么想法吗?
我尝试使用Maven故障安全插件http://maven.apache.org/surefire/maven-failsafe-plugin/examples/skipping-test.html
并添加到我的pom.xml中...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.10</version>
<configuration>
<skipITs>true</skipITs>
</configuration>
</plugin>
但是mvn clean install仍在运行功能测试。 不知道为什么grails如此固执。
我真的只是担心跳过grails-maven功能测试,也许对于您的情况,您可以尝试:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
</configuration>
终于找到了解决方法,如果有人偶然发现本文,可以跳过grails-maven-function-test。 它需要maven 2.2或更高版本,并将其添加到pom.xml中:
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>${grails.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>default-maven-functional-test</id>
<phase>integration-test</phase>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.