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>
  • 相关阅读:
    C#磁吸屏幕窗体类库
    准备
    我写的诗
    How to turn off a laptop keyboard
    How to tell which commit a tag points to in Git?
    Why should I care about lightweight vs. annotated tags?
    How to get rid of “would clobber existing tag”
    Facebook, Google and Twitter threaten to leave Hong Kong over privacy law changes
    The need for legislative reform on secrecy orders
    Can a foreign key be NULL and/or duplicate?
  • 原文地址:https://www.cnblogs.com/buhaiqing/p/3420198.html
Copyright © 2011-2022 走看看