Just from my experience, having used both, I'll make a few comments on
this (p.s. I am far from an expert on both).
Spock
Cons:
- It's built on top of junit, so it is still plagued to an extent by
the same issues Cedric complained about for writing TestNG (http://
beust.com/weblog/2004/02/08/junit-pain/ and
http://beust.com/weblog/2004/08/25/testsetup-and-evil-static-methods/)
. e.g. you can't externalize your test suite in an XML or selective
choose why group of tests to run like you would with TestNG, or set up
test dependencies, to name a few.
- Requires learning groovy. Not a steep learning curve since Groovy is
mainly Java, but on steroids!
Pros:
- Start by reading
http://code.google.com/p/spock/wiki/WhySpock
- Since spock test are written in groovy, you harness all the power of
groovy in writing your test cases (this is a BIG win IMO!).
- Mocking is way easier and more expressive than depending on other
third party libraries (if you were using TestNG)
- It's easier and more expressive to read and write
- Extensions are easy to write (if the need arises)
- Power asserts built right in (very very nice, even though you can
get something similar using hamcrest matching library with your TestNG
tests)
I have been using Spock more and more, and really liking it, even
though sometimes I wish it came out of the box with some of the
features I love so much about TestNG.
Cheers