• HelloSpock


    <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/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>hello</groupId>
        <artifactId>hello_spock</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
    
        <name>hello_spock</name>
        <url>http://maven.apache.org</url>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        </properties>
    
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <compilerId>groovy-eclipse-compiler</compilerId>
                        <verbose>true</verbose>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy-eclipse-compiler</artifactId>
                            <version>2.7.0-01</version>
                        </dependency>
                    </dependencies>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.18.1</version>
                    <configuration>
                        <includes>
                            <include>**/*Spec.java</include>
                            <include>**/*Test.java</include>
                        </includes>
                    </configuration>
                </plugin>
    
            </plugins>
        </build>
    
        <dependencies>
            <dependency>
                <groupId>org.spockframework</groupId>
                <artifactId>spock-core</artifactId>
                <version>1.1-groovy-2.4</version>
                <scope>test</scope>
            </dependency>
            <!-- Optional dependencies for using Spock -->
            <dependency> <!-- use a specific Groovy version rather than the one specified by spock-core -->
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <version>2.4.13</version>
            </dependency>
        </dependencies>
    </project>
    class AppGroovy {
    public static void main(String[] args)  {
      def closure = { param -> println "hello ${param}" }
      closure("world")
    }
    }
    package hello.hello_spock
    
    class HelloSpockSpec extends spock.lang.Specification  {
      def "length of Spock's and his friends' names"() {
        expect:
        name.size() == length
    
        where:
        name     | length
        "Spock"  | 5
        "Kirk"   | 4
        "Scotty" | 6
      }
    } 
    package hello.hello_spock;
    
    public class Sum {
      public int sum(int a,int b){
        return a+b;
        }
    }
    package hello.hello_spock
    
    import spock.lang.Specification;
    class SumTest extends Specification {
        def sum = new Sum();
        def "sum should return param1+param2"() {
            expect:
            sum.sum(1,1) == 2 
        }  
    }
  • 相关阅读:
    16、springboot——错误处理原理+定制错误页面(1)
    15、springboot——CRUD-跳转到修改员工页面+员工修改和删除实现 ⑥
    14、springboot——CRUD-跳转到添加员工页面+员工添加实现⑤
    13、springboot——CRUD-thymeleaf公共页面元素抽取④
    12、springboot——CRUD登录和拦截③
    11、springboot——CRUD国际化②
    10、springboot——CRUD导入静态资源以及设置默认访问首页①
    9、springmvc的自动配置
    8、模板引擎thymeleaf(百里香叶)
    7、对静态资源映射的规则
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/8474534.html
Copyright © 2020-2023  润新知