Spock without maven or gradle
Asked Answered
C

2

8

I have a standard Java project that uses ant for building. I would like to add spock testing to this project without disrupting the current process. What is the minimum set of changes that would allow me to start to integrate spock testing into this project.

There is not much available information on spock integration into legacy projects using ant.

Coh answered 6/9, 2011 at 5:42 Comment(0)
W
7

If you have a mix of jUnit and Spock tests in your test package (like we do), you can use the joint compilation feature of groovyc, something like this:

    <groovyc srcdir="${testSrcDir}" destdir="${testTarget}" classpathref="testCompileClasspath">
        <javac deprecation="on" debug="on"/>
    </groovyc> 

This will automagically compile both the Java and Groovy tests together. From this point on, you can run the tests as before using the junit task.

Waldo answered 29/11, 2011 at 18:12 Comment(0)
C
5

You just need to compile your Spock tests with the groovyc Ant task (with Spock on the class path), and run them with the junit Ant task (again with Spock on the class path). Have a look at the spock-example zip, which comes with an Ant build. (You might have to bump the version of maven-ant-tasks to make that build work).

Cantor answered 6/9, 2011 at 7:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.