zoukankan      html  css  js  c++  java
  • 【Groovy】Spock with Maven

    已经在项目里使用Groovy/Spock做测试框架了,感觉和Maven结合在一起还是挺好用的。

    在Maven的pom.xml里引入他们还是挺方便的,第一先要在dependency 里引入

            <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <version>1.8.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.spockframework</groupId>
                <artifactId>spock-core</artifactId>
                <version>0.6-groovy-1.8</version>
                <scope>test</scope>
            </dependency>

    接着是要在Plugin部分做些配置

        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>test-compile</id>
                            <phase>test-compile</phase>
                            <configuration>
                                <tasks>
                                    <taskdef classname="org.codehaus.groovy.ant.Groovyc" name="groovyc">
                                        <classpath refid="maven.test.classpath"/>
                                    </taskdef>
                                    <mkdir dir="${project.build.outputDirectory}"/>
                                    <mkdir dir="${project.build.testOutputDirectory}"/>
                                    <groovyc destdir="${project.build.testOutputDirectory}" listfiles="true" srcdir="${basedir}">
                                        <classpath refid="maven.test.classpath"/>
                                    </groovyc>
    
                                    <ant antfile="${basedir}/build.xml" target="groovytarget">  
                                        
                                    </ant>
                                </tasks>
                            </configuration>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>ant</groupId>
                            <artifactId>ant-nodeps</artifactId>
                            <version>1.6.5</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.spockframework</groupId>
                    <artifactId>spock-maven</artifactId>
                    <version>0.6-groovy-1.8</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>find-specs</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <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>
    
                            <configuration>
                                <debug>true</debug>
                                <verbose>true</verbose>
                                <stacktrace>true</stacktrace>
                                <defaultScriptExtension>.groovy</defaultScriptExtension>
                                <providerSelection>1.7</providerSelection>
                                <source>
                                    <fileset>
                                        <directory>${pom.dir}</directory>
                                        <includes>
                                            <include>**/groovy/*.groovy</include>
                                        </includes>
                                    </fileset>
    
    
                                </source>
                            </configuration>
                        </execution>
    
                    </executions>
                </plugin>
            </plugins>
        </build>
  • 相关阅读:
    Layui的一些心得
    Oracle工具PLSQL
    .NET开发中 springMVC+NHibernate注入失败的几个常见错误
    配置好运行后Error creating context 'spring.root': Could not load type from string value
    css样式添加错误导致烦扰
    Oracle时间与系统不同步,TimeStampService
    前端入门10-JavaScript语法之对象
    前端入门9-JavaScript语法之运算符
    前端入门8-JavaScript语法之数据类型和变量
    前端入门7-JavaScript语法之相关术语
  • 原文地址:https://www.cnblogs.com/buhaiqing/p/3420198.html
Copyright © 2011-2022 走看看