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>
  • 相关阅读:
    vim使用技巧
    排序
    2020-3-27 学习面向对象的笔记
    小圆圈第三章答案
    内置函数部分用法
    Pycharm快捷键
    小猿圈第二章答案
    Typora学习笔记
    AI的真实感
    Unity 横版2D移动跳跃问题——关于一段跳与二段跳
  • 原文地址:https://www.cnblogs.com/buhaiqing/p/3420198.html
Copyright © 2011-2022 走看看