|
Hi all,
I have a unit test for a controller which makes a call to a custom taglib. In my unit test I am using the GroovyPageUnitTestMixin and then calling mockTagLib to make the custom taglib available to the controller method when it is called. So my controller unit test looks like: @Mixin(GroovyPageUnitTestMixin) @TestFor(MyController) @Mock([MyDomain]) class MyControllerTests { ... void myTestMethod(){ mockTagLib(com.mypackage.MyTagLib) ... // create various mock domains ... controller.show() // bunch of assertions } } and this works perfectly when I run this test in isolation. However when I come to run all my tests together, ie calling: grails test-app -coverage this unit test fails on the call to mockTagLib() with the following message (class & package names changed, obviously): groovy.lang.MissingMethodException: No signature of method: com.mypackage.MyControllerTests.mockTagLib() is applicable for argument types: (java.lang.Class) values: [class com.mypackage.MyTagLib] Possible solutions: mockDomain(java.lang.Class) Even the presence of just one other controller test class seems to prevent this one from running correctly and I am baffled as to why. Being reasonably new to Grails unit testing, I dont really know where to start with this one - can anyone suggest why the GroovyPageUnitTestMixin would fail to inject the mockTagLib method into my unit test class when run in conjunction with other tests? Is there something that I should be clearing down in other tests which I am failing to do? Grails version is v2.0.1 Cheers in advance Bryn |
|
I've seen a similar issue where Mixins are nuked under certain test scenarios (usually related to Junit). I'll be keen to hear what others have seen.
On Wed, Jul 11, 2012 at 10:04 AM, brynblackcap <[hidden email]> wrote: Hi all, |
|
In reply to this post by brynblackcap
Ok so I managed to resolve this issue by removing the mixin annotation and the call to mockTagLib, and simply adding the taglib class to the list of classes in the @Mock annotation. so my original code above now becomes
@TestFor(MyController) @Mock([MyDomain, MyTagLib]) class MyControllerTests { ... void myTestMethod(){ ... // create various mock domains ... controller.show() // bunch of assertions } } Problem seems now to be solved. As to why it broke using the original method, I have no idea. |
| Powered by Nabble | Edit this page |
