开发者

Spock without maven or gradle

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.


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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜