<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
}
}

HelloSpock的更多相关文章

随机推荐

  1. Kindergarten

    传送门:http://poj.org/problem?id=3692 Language:KindergartenTime Limit: 2000MS Memory Limit: 65536KTotal ...

  2. 洛谷【P2005】A/B Problem II

    题目传送门:https://www.luogu.org/problemnew/show/P2005 高精除低精:https://www.cnblogs.com/AKMer/p/9724556.html ...

  3. Go语言是如何处理栈的

    转自:http://tonybai.com/2014/11/05/how-stacks-are-handled-in-go/ Go 1.4Beta1刚刚发布,在Go 1.4Beta1中,Go语言的st ...

  4. CRT Library Features

    CRT Library Features The new home for Visual Studio documentation is Visual Studio 2017 Documentatio ...

  5. ES6学习之Symbol

    定义:一种新的原始数据类型,表示独一无二的值 const a = Symbol(); const b = Symbol("foo") //接收参数的Symbol,参数表示对Symb ...

  6. linux日常管理-防火墙netfilter工具-iptables-1

    防火墙的名字叫 netfilter 工具/命令叫iptables 命令:iptables 选项: -t   指定表 -A 在最上面增加一条规则 -I 在最下面增加一条规则 -D 删除一条规则 -A-I ...

  7. SVN使用技巧和参考文档总结

    以下文章为网上收集: myEclipse 8.5下SVN环境的搭建(重点推荐) SVN建立版本库,配置用户和权限 Tortoise SVN使用方法,简易图解 版本控制软件SVN使用方法详解 学习笔记 ...

  8. HTTP ERROR

    HTTP 400 – 请求无效HTTP 401.1 – 未授权:登录失败HTTP 401.2 – 未授权:服务器配置问题导致登录失败HTTP 401.3 – ACL 禁止访问资源HTTP 401.4 ...

  9. 09_android项目的目录结构

    R.java是由IDE自动生成的,不允许修改. Android Dependences  安卓的支持库 项目创建之后一般都会把安卓支持库的V4包导入进来. 项目打包的时候assets的内容并不会被编译 ...

  10. TortoiseSVN 日常操作指南

    TortoiseSVN A Subversion client for Windows Stefan Küng Lübbe Onken Simon Large 2005/01/17 19:09:21 ...