Update to 2.0 and remove ANT example

main
Leonard Brünings 5 years ago
parent 7d23104820
commit f1491efa0e

@ -1 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip

@ -1,58 +1,50 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/spockframework/spock/blob/master/LICENSE) [.float-group]
[![Build Status](https://img.shields.io/travis/spockframework/spock-example/master.svg?label=Build)](https://travis-ci.org/spockframework/spock-example) --
[![Gitter](https://badges.gitter.im/spockframework/spock.svg)](https://gitter.im/spockframework/spock?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) image::https://img.shields.io/badge/License-Apache%202.0-blue.svg[link=https://github.com/spockframework/spock/blob/master/LICENSE,float=left]
image::https://img.shields.io/travis/spockframework/spock-example/master.svg?label=Build[link=https://travis-ci.org/spockframework/spock-example,float=left]
image::https://badges.gitter.im/spockframework/spock.svg[link=https://gitter.im/spockframework/spock?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge,float=left]
--
== Spock Framework Example Project
Spock Framework Example Project
===============================
The purpose of this project is to help you get started with Spock. The project includes several example specifications and build scripts for Ant, Gradle, and Maven. It also makes it easy to create an Eclipse or IDEA project, allowing you to run the example specs from within your IDE. The purpose of this project is to help you get started with Spock. The project includes several example specifications and build scripts for Ant, Gradle, and Maven. It also makes it easy to create an Eclipse or IDEA project, allowing you to run the example specs from within your IDE.
All three builds (Ant, Gradle, Maven) will automatically download all required dependencies, compile the project, and finally run the example specs. The Gradle build goes one step further by bootstrapping itself, alleviating the need to have a build tool preinstalled. All three builds (Ant, Gradle, Maven) will automatically download all required dependencies, compile the project, and finally run the example specs. The Gradle build goes one step further by bootstrapping itself, alleviating the need to have a build tool preinstalled.
Prerequisites === Prerequisites
-------------
- JDK 7 or higher - JDK 8 or higher
- Maven use `mvnw` wrapper - Maven use `mvnw` wrapper
- Gradle use `gradlew` wrapper - Gradle use `gradlew` wrapper
- Ant 1.7 or higher (for Ant build)
Building with Ant NOTE: This example shows the usage of Spock 2.0, which uses the JUnit Platform. If you want to see how to get Spock 1.x with JUnit 4 up and running see the https://github.com/spockframework/spock-example/tree/spock-1.x[Spock-1.x] Branch.
-----------------
Type:
ant clean test === Building with Gradle
Downloaded files will be stored in the local Maven repository (typically *user_home*`/.m2/repository`).
Building with Gradle
--------------------
Type: Type:
./gradlew clean test ./gradlew clean test
Downloaded files (including the Gradle distribution itself) will be stored in the Gradle user home directory (typically *user_home*`/.gradle`). Downloaded files (including the Gradle distribution itself) will be stored in the Gradle user home directory (typically *user_home*`/.gradle`).
Building with Maven === Building with Maven
-------------------
Type: Type:
./mvnw clean test ./mvnw clean test
Downloaded files will be stored in the local Maven repository (typically *user_home*`/.m2/repository`). Downloaded files will be stored in the local Maven repository (typically *user_home*`/.m2/repository`).
Creating an Eclipse project === Creating an Eclipse project
---------------------------
Type: Type:
./gradlew cleanEclipse eclipse ./gradlew cleanEclipse eclipse
Make sure you have a recent version of the Groovy Eclipse plugin installed. After importing the generated project into a workspace, go to Preferences->Java->Build Path->Classpath Variables and add a variable named `GRADLE_CACHE` with value *user_home*`/.gradle/cache`. (If you have an environment variable `GRADLE_USER_HOME` set, the correct value is *GRADLE_USER_HOME*`/cache`.) You should now be able to build the project, and to run the specs like you would run a JUnit test. See http://wiki.spockframework.org/GettingStarted#Eclipse for more information on how to get started with Spock and Eclipse. Make sure you have a recent version of the Groovy Eclipse plugin installed. After importing the generated project into a workspace, go to Preferences->Java->Build Path->Classpath Variables and add a variable named `GRADLE_CACHE` with value *user_home*`/.gradle/cache`. (If you have an environment variable `GRADLE_USER_HOME` set, the correct value is *GRADLE_USER_HOME*`/cache`.) You should now be able to build the project, and to run the specs like you would run a JUnit test. See http://wiki.spockframework.org/GettingStarted#Eclipse for more information on how to get started with Spock and Eclipse.
Creating an IDEA project === Creating an IDEA project
---------------------------
Just open the project directory with Intelli IDEA and it should auto-detect the project settings. Just open the project directory with Intelli IDEA and it should auto-detect the project settings.
Alternativly Type: Alternatively Type:
./gradlew cleanIdea idea ./gradlew cleanIdea idea
@ -60,34 +52,33 @@ Open the generated project in IDEA. You should now be able to build the project,
NOTE: you might also want to install https://github.com/mycila/gmavenplus-intellij-plugin so that `src/test/groovy` is correctly recognized as a test classes root. NOTE: you might also want to install https://github.com/mycila/gmavenplus-intellij-plugin so that `src/test/groovy` is correctly recognized as a test classes root.
Getting hold of the Jars used in this project === Getting hold of the Jars used in this project
---------------------------------------------
Type: Type:
./gradlew collectJars ./gradlew collectJars
The Jars will be copied to `build/output/lib`. The comments in `build.gradle` explain what they are needed for. The Jars will be copied to `build/output/lib`. The comments in `build.gradle` explain what they are needed for.
Further Resources === Further Resources
-----------------
* [Spock homepage](http://spockframework.org) * http://spockframework.org[Spock homepage]
* [Spock web console](https://meetspock.appspot.com) * https://meetspock.appspot.com[Spock web console]
* [Main documentation](http://docs.spockframework.org/) * http://docs.spockframework.org/[Main documentation]
* [User discussion group](http://forum.spockframework.org) * http://forum.spockframework.org[User discussion group]
* [Dev discussion group](http://dev.forum.spockframework.org) * http://dev.forum.spockframework.org[Dev discussion group]
* [Issue tracker](http://issues.spockframework.org) * http://issues.spockframework.org[Issue tracker]
* [Build server](http://builds.spockframework.org) * http://builds.spockframework.org[Build server]
* [Spock blog](http://blog.spockframework.org) * http://blog.spockframework.org[Spock blog]
* [Spock on Twitter](https://twitter.com/spockframework) * https://twitter.com/spockframework[Spock on Twitter]
* [Ant homepage](http://ant.apache.org) * http://ant.apache.org[Ant homepage]
* [Gradle homepage](http://www.gradle.org) * http://www.gradle.org[Gradle homepage]
* [Groovy homepage](http://groovy-lang.org/) * http://groovy-lang.org/[Groovy homepage]
* [Maven homepage](http://maven.apache.org) * http://maven.apache.org[Maven homepage]
If you have any comments or questions, please direct them to the Spock discussion group. All feedback is appreciated! If you have any comments or questions, please direct them to the Spock discussion group. All feedback is appreciated!
Happy spec'ing! Happy spec'ing!
Peter Niederwieser
Creator, Spock Framework The Spock Framework Team

@ -3,8 +3,8 @@ apply plugin: "groovy"
version = "1.0" version = "1.0"
description = "Spock Framework - Example Project" description = "Spock Framework - Example Project"
// Spock works with Java 1.7 and above // Spock works with Java 1.8 and above
sourceCompatibility = 1.7 sourceCompatibility = 1.8
repositories { repositories {
// Spock releases are available from Maven Central // Spock releases are available from Maven Central
@ -15,8 +15,10 @@ repositories {
dependencies { dependencies {
// mandatory dependencies for using Spock // mandatory dependencies for using Spock
compile "org.codehaus.groovy:groovy-all:2.5.7" compile "org.codehaus.groovy:groovy-all:2.5.8"
testCompile "org.spockframework:spock-core:1.3-groovy-2.5" testCompile platform("org.spockframework:spock-bom:2.0-M1-groovy-2.5")
testCompile "org.spockframework:spock-core"
testCompile "org.spockframework:spock-junit4" // you can remove this if your code does not rely on old JUnit 4 rules
// optional dependencies for using Spock // optional dependencies for using Spock
testCompile "org.hamcrest:hamcrest-core:1.3" // only necessary if Hamcrest matchers are used testCompile "org.hamcrest:hamcrest-core:1.3" // only necessary if Hamcrest matchers are used
@ -35,6 +37,11 @@ task collectJars(type: Copy) {
into "$buildDir/output/lib" into "$buildDir/output/lib"
from configurations.testRuntime from configurations.testRuntime
} }
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}

@ -1,112 +0,0 @@
<project name="SpockExample" basedir="." default="test" xmlns:artifact="urn:maven-artifact-ant">
<property name="src.dir" location="src/test/groovy" />
<property name="resource.dir" location="src/test/resources" />
<property name="build.dir" location="ant/build" />
<property name="lib.dir" location="ant/lib" />
<property name="maven.ant.tasks.url" value="https://central.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar" />
<property name="maven.ant.tasks.jar" value="${lib.dir}${file.separator}maven-ant-tasks-2.1.3.jar" />
<available property="maven.ant.tasks.jar.exists" file="${maven.ant.tasks.jar}" />
<target name="bootstrap.maven.tasks" unless="maven.ant.tasks.jar.exists">
<mkdir dir="${lib.dir}" />
<get
src="${maven.ant.tasks.url}"
dest="${maven.ant.tasks.jar}" />
</target>
<target name="init.maven.tasks" depends="bootstrap.maven.tasks">
<typedef
resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpath="${maven.ant.tasks.jar}" />
</target>
<target name="resolve.dependencies" depends="init.maven.tasks">
<artifact:dependencies pathId="classpath.spock">
<!-- Mandatory dependencies for using Spock -->
<dependency
groupId="org.spockframework"
artifactId="spock-core"
version="1.1-groovy-2.4" />
<!-- Optional dependencies for using Spock -->
<!-- enables mocking of classes (in addition to interfaces) -->
<dependency
groupId="net.bytebuddy"
artifactId="byte-buddy"
version="1.6.5" />
<!-- enables mocking of classes without parameterless constructor (together with CGLIB) -->
<dependency
groupId="org.objenesis"
artifactId="objenesis"
version="2.5.1" />
<!-- only required if Spock's Ant selector is used, which finds spec classes regardless of their name -->
<dependency
groupId="org.ow2.asm"
artifactId="asm"
version="5.0.3" />
<!-- only required if Hamcrest matchers are used -->
<dependency
groupId="org.hamcrest"
artifactId="hamcrest-core"
version="1.3" />
<!-- Dependencies used by examples in this project (not required for using Spock) -->
<dependency
groupId="com.h2database"
artifactId="h2"
version="1.4.182" />
<remoteRepository
id="maven-central"
url="https://repo1.maven.org/maven2/" />
<!-- Only required if a snapshot version of Spock is used -->
<remoteRepository
id="spock-snapshots"
url="https://oss.sonatype.org/content/repositories/snapshots/" />
</artifact:dependencies>
</target>
<target name="init.groovy.tasks" depends="resolve.dependencies">
<!-- Using the Groovy compiler from classpath.spock is a simple and safe setup -->
<taskdef
name="groovyc"
classname="org.codehaus.groovy.ant.Groovyc"
classpathref="classpath.spock" />
</target>
<target name="init" depends="init.groovy.tasks">
<tstamp />
<mkdir dir="${build.dir}" />
</target>
<target name="copy.resources" depends="init">
<copy todir="${build.dir}">
<fileset dir="${resource.dir}" />
</copy>
</target>
<target name="compile" depends="copy.resources">
<groovyc
srcdir="${src.dir}"
destdir="${build.dir}"
classpathref="classpath.spock" />
</target>
<target name="test" depends="compile">
<junit fork="true" forkmode="once">
<classpath path="${build.dir}" />
<classpath refid="classpath.spock" />
<batchtest>
<fileset dir="${build.dir}">
<custom
classname="org.spockframework.buildsupport.ant.SpecClassFileSelector"
classpathref="classpath.spock" />
</fileset>
</batchtest>
<formatter type="brief" usefile="false" />
</junit>
</target>
<target name="clean">
<delete dir="${build.dir}" />
</target>
</project>

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip distributionSha256Sum=d364b7098b9f2e58579a3603dc0a12a1991353ac58ed339316e6762b21efba44
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

6
gradlew vendored

@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
# You may obtain a copy of the License at # You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # https://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`

2
gradlew.bat vendored

@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License. @rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at @rem You may obtain a copy of the License at
@rem @rem
@rem http://www.apache.org/licenses/LICENSE-2.0 @rem https://www.apache.org/licenses/LICENSE-2.0
@rem @rem
@rem Unless required by applicable law or agreed to in writing, software @rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS, @rem distributed under the License is distributed on an "AS IS" BASIS,

@ -35,7 +35,7 @@
<!-- Only required if names of spec classes don't match default Surefire patterns (`*Test` etc.) --> <!-- Only required if names of spec classes don't match default Surefire patterns (`*Test` etc.) -->
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version> <version>3.0.0-M4</version>
<configuration> <configuration>
<useFile>false</useFile> <useFile>false</useFile>
<includes> <includes>
@ -55,20 +55,35 @@
</plugins> </plugins>
</build> </build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-bom</artifactId>
<version>2.0-M1-groovy-2.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<!-- Mandatory dependencies for using Spock --> <!-- Mandatory dependencies for using Spock -->
<dependency> <dependency>
<groupId>org.spockframework</groupId> <groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId> <artifactId>spock-core</artifactId>
<version>1.3-groovy-2.5</version> <scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-junit4</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- Optional dependencies for using Spock --> <!-- Optional dependencies for using Spock -->
<dependency> <!-- use a specific Groovy version rather than the one specified by spock-core --> <dependency> <!-- use a specific Groovy version rather than the one specified by spock-core -->
<groupId>org.codehaus.groovy</groupId> <groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy</artifactId>
<version>2.5.7</version> <version>2.5.8</version>
<type>pom</type>
</dependency> </dependency>
<dependency> <!-- enables mocking of classes (in addition to interfaces) --> <dependency> <!-- enables mocking of classes (in addition to interfaces) -->
<groupId>net.bytebuddy</groupId> <groupId>net.bytebuddy</groupId>

Loading…
Cancel
Save