Skip to content

Instantly share code, notes, and snippets.

@lyhcode
Created November 2, 2011 07:19
Show Gist options
  • Save lyhcode/1333078 to your computer and use it in GitHub Desktop.
Save lyhcode/1333078 to your computer and use it in GitHub Desktop.
Gradle + Spock Unit Test
apply plugin: 'java'
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
groovy 'org.codehaus.groovy:groovy-all:1.8.3'
testCompile 'org.spockframework:spock-core:0.5-groovy-1.8'
}
package com.example;
public class Hello {
public String sayHello(String who) {
return "Hello, " + who;
}
}
import spock.lang.Specification
import com.example.Hello
class HelloSpec extends Specification {
def "say hello to everyone"() {
expect:
new Hello().sayHello(name) == words
where:
name | words
'John' | 'Hello, John'
'Joe' | 'Hello, Joe'
'Mary' | 'Hello, Mary'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment