Created
November 2, 2011 07:19
-
-
Save lyhcode/1333078 to your computer and use it in GitHub Desktop.
Gradle + Spock Unit Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
public class Hello { | |
public String sayHello(String who) { | |
return "Hello, " + who; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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