<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. 牛客网字节跳动冬令营网络赛J Sortable Path on Tree —— 点分治

    题目:https://ac.nowcoder.com/acm/contest/296/J 用点分治: 记录了值起伏的形态,二元组 (x,y) 表示有 x 个小于号,y 个大于号: 因为小于号和大于号都 ...

  2. ssh免密码登录配置方法,(图示加命令)

    首先,说明一下我们要做的是,serverA 服务器的 usera 用户免密码登录 serverB 服务器的 userb用户. 我们先使用usera 登录 serverA 服务器 [root@serve ...

  3. shell ## %% 使用说明

    path='apps/home/usr/app/test.txt' a=${path##*/} b=${path#*/} c=${path%%/*} d=${path%/*}············· ...

  4. HDOJ1166(线段树点修改)

    敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  5. 【转】 Pro Android学习笔记(二八):用户界面和控制(16):GridLayout

    网格布局:GridLayout 我个人觉得GridLayout的设计还不很完善,每个网格的大小,由填充的cell决定,即默认是wrap很容易整个GridLayout超出屏幕.下面是一个例子: < ...

  6. GCC提供的几个內建函数

    参考 https://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Other-Builtins.html#Other-Builtins https://en.wikipe ...

  7. 共有11款Python 中文分词库开源软件

    件过滤: 排序: 收录时间 | 浏览数 Python 中文分词库 Yaha "哑哈"中文分词,更快或更准确,由你来定义.通过简单定制,让分词模块更适用于你的需求. "Ya ...

  8. zabbix 系列 (1)安装

    安装server http://blog.csdn.net/xiegh2014/article/details/54988548 安装 agent http://m.blog.csdn.net/wu2 ...

  9. 使用python+requests对接口进行测试

    import unittestimport requestsimport json class Login(unittest.TestCase): def setUp(self): self.base ...

  10. 关于Android阻塞的解决方法

    首先新建一个线程,然后有两种方法 1.POST方法(直接,但是可读性差) 2.使用AnycTask类,可读性好,而且是POST方法的封装