How to migrate or convert a JUnit/JMock test cases into Spock test cases without manual coding.?

Skip to first unread message

Mahendra Kumar

Mar 16, 2015, 11:09:40 PM3/16/15
In our project we have around 13,000 JUnit/JMock test cases. Now we are planning to convert all of them into Spock Test cases. We are looking for the approach or a tool where we can convert the JUnit/JMock test cases to Spock test cases automatically to avoid the manual effort and time lag as the test cases count is 13,000.  Is there any tool or framework available to do this.? Could you please any one suggest me for my requirement. We are expecting  60-80% at least to convert the test cases by using any tool or framework, other part will take care by the manual effort(coding entire test cases in to Spock by analyzing existing JUnit/JMock test cases). 

Thanks in adv. 

Leonard Brünings

Mar 24, 2015, 1:11:08 PM3/24/15

I don't know of any framework that could do that. And even if you could convert those junit test to spock syntax they would not really be spock tests, since most likely they will not follow the Spock structure.
You can however use Spock together with JUnit tests, and whenever you write a new one or refactor an existing one you can do it in Spock. This way you can gradually convert to Spock without the need to
invest a huge amount of time at the start.

Mar 24, 2015, 7:45:45 PM3/24/15
Spock tests will run happily alongside existing JUnit test cases. It seems to me a huge effort for very little gain to translate existing tests that are (presumably) working for you right now. There is nothing that can sensibly automate that.

Łukasz Opaluch

May 14, 2017, 9:53:28 PM5/14/17
to Spock Framework - User
I know that this is pretty old thread, but I hope someone finds this useful: I have created small Java tool which migrates Junit/Mockito based tests into Spock specs.
You can find it on Github.

Kostis Kapelonis

May 16, 2017, 12:25:24 AM5/16/17
Very cool!

Thanks for sharing.

Have you used it in a production project? Or this is just a prototype?

> --
> You received this message because you are subscribed to the Google Groups
> "Spock Framework - User" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
> To post to this group, send email to
> Visit this group at
> For more options, visit

Łukasz Opaluch

May 22, 2017, 7:29:44 PM5/22/17
to Spock Framework - User
I am quite sure that I've anserved this but somehow it has not been published. Anyway, I've used this tool on some random projects from github and on one medium size production project and it performed rather well. Still, I can think about many useful features that could be implemented to make migration even easier. I've published it to get some feedback how it could be improved further to hadle more use cases.
Reply all
Reply to author
0 new messages