I've been playing around with ScalaMock, but I could not figure out
how to use its compiler plugin together with gradle and eclipse.
Can anyone give me some hints how to get this to work?
Regards,
Nicolas
I'm afraid that I know next-to-nothing about Gradle, so I can't give you any direct advice. But I can tell you that just enabling the plugin isn't enough :-)
It's worth noting that ScalaMock can be used directly (without the compiler plugin or any build system hackery) if you just want to use function or proxy mocks. What follows is only necessary if you want "power" features such as mocking object creation or singleton/companion objects.
Using generated mocks requires the following steps:
1) Run the compiler with the -P:scalamock:generatemocks and -P:scalamock:generatetest arguments. This will search for @mock annotations and generate two different directories containing source code for each mocked class.
2) Run the compiler again to compile the contents of the generated mocks directory into a separate .jar file.
3) Compile your test code together with the contents of the generated tests directory.
4) When you run your tests (assuming that you're using ScalaTest) pass the "-Dmock.classes" argument, passing the path of the .jar file you created in step 2.
You can see how this is achieved for sbt here:
https://github.com/paulbutcher/scalamock-sbt-plugin/blob/master/src/main/scala/ScalaMockPlugin.scala
I'd be delighted if you (or anyone else) felt like contributing gradle (or Maven, or Eclipse, or...) integration back to ScalaMock and will help in any way I can if you decide to take this on :-)
--
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher