forked from swkBerlin/kata-bootstraps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swkBerlin#34 from gsaslis/master
Add spock base project (java)
- Loading branch information
Showing
3 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>swkBerlin</groupId> | ||
<artifactId>spock</artifactId> | ||
<version>1.0</version> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
|
||
<groovy.core.version>2.4.11</groovy.core.version> | ||
<groovy.spock.version>1.2-groovy-2.4</groovy.spock.version> | ||
<groovy.gmaven.pluginVersion>1.6.1</groovy.gmaven.pluginVersion> | ||
|
||
|
||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>versions-maven-plugin</artifactId> | ||
<version>2.5</version> | ||
</dependency> | ||
<!-- Mandatory dependencies for using Spock --> | ||
<dependency> | ||
<groupId>org.spockframework</groupId> | ||
<artifactId>spock-core</artifactId> | ||
<version>${groovy.spock.version}</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>${groovy.core.version}</version> | ||
</dependency> | ||
<dependency> <!-- enables mocking of classes (in addition to interfaces) --> | ||
<groupId>net.bytebuddy</groupId> | ||
<artifactId>byte-buddy</artifactId> | ||
<version>1.9.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> <!-- enables mocking of classes without default constructor (together with CGLIB) --> | ||
<groupId>org.objenesis</groupId> | ||
<artifactId>objenesis</artifactId> | ||
<version>2.6</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> <!-- only required if Hamcrest matchers are used --> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-core</artifactId> | ||
<version>1.3</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<!-- Mandatory plugins for using Spock --> | ||
<plugin> | ||
<!-- The gmavenplus plugin is used to compile Groovy code. To learn more about this plugin, | ||
visit https://github.com/groovy/GMavenPlus/wiki --> | ||
<groupId>org.codehaus.gmavenplus</groupId> | ||
<artifactId>gmavenplus-plugin</artifactId> | ||
<version>${groovy.gmaven.pluginVersion}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
<goal>compileTests</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- Optional plugins for using Spock --> | ||
<!-- Only required if names of spec classes don't match default Surefire patterns (`*Test` etc.) --> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.1</version> | ||
<configuration> | ||
<useFile>false</useFile> | ||
<includes> | ||
<include>**/*Test.java</include> | ||
<include>**/*Spec.java</include> | ||
</includes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
public class Thing { | ||
|
||
public String callForAction() { | ||
return "Dog"; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import spock.lang.Specification | ||
|
||
class ThingSpec extends Specification { | ||
|
||
def "it should call for action"() { | ||
given: "some Thing" | ||
Thing thing = new Thing() | ||
|
||
when: "an action is called on it" | ||
String value = thing.callForAction() | ||
|
||
then: "it should return 'Food'" | ||
"Food" == value | ||
} | ||
} |