-
Notifications
You must be signed in to change notification settings - Fork 37.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Aspects to provide basic static mock test functionality [SPR-6274] #10941
Comments
Ben Alex commented I just tested (via mvn test) a Roo-built app against Spring Framework 3.0.0.BUILD-20091028.205923-196 (using roo script vote.roo). It gives the following error: [ERROR] can't determine annotations of missing type org.junit.Test The pom.xml for this project contains a declaration for JUnit, but with a <scope>test</scope>. If I change the scope to compile, the tests pass. As such I am wondering whether the movement of the aspects to the Spring Aspects library might be responsible for this? Perhaps we might need a Spring Aspects library that has scope at testing time only? |
Ramnivas Laddad commented Fixed by marking junit dependency as 'compile'. Since mocking aspects depend on junit at compile time, this is the right scope, anyway. |
Ben Alex commented The trouble with making it "compile" scope is that JUnit will then appear in the resulting WAR's WEB-INF/lib directory. I just quickly looked over the code for this feature and JUnitStaticEntityMockingControl appears to be the only type that requires Junit at all anyway (specifically for the pointcut expression). In view of this it doesn't seem such a bad idea to just remove the |
Ramnivas Laddad commented Ben, one problem I see with removing |
Ben Alex commented Do you mean using scope "provided" in the Spring Aspects POM for JUnit, and then having the end user project's POM include a JUnit dependency with a scope of "test"? If so, that will work fine when compiling the tests but I suspect will fail when compiling the normal classes earlier in the build. The failure will be because the "compile" phase references Spring Aspect and it in turn expects JUnit to be in the classpath, but the user project's scope would prohibit that from being included until the "test" phase. Perhaps I'm missing something? Regarding just removing the We still have the other two options identified earlier, being to split this feature out from Spring Aspects into Spring Test Aspects, or just live with the junit.jar appearing in the resulting WAR files and direct people to this issue so they can see the background. My only reservation with the latter (aside from WAR payload, which I am always trying to minimise as a general principle) is that most people won't even do static mock testing yet this JUnit dependency will be required by every person who is using Spring Aspects. |
Ben Alex opened SPR-6274 and commented
Spring Roo presently supports creation of mocks for static methods. As per email discussion between Juergen, Ramnivas and Ben, it would be useful if these classes were ported to Spring Aspects.
Please see the following location in Spring Roo code for the templates to use:
https://fisheye.springsource.org/browse/spring-roo/trunk/addon-test/src/main/resources/org/springframework/roo/addon/test/AbstractMethodMockingControl.aj-template
https://fisheye.springsource.org/browse/spring-roo/trunk/addon-test/src/main/resources/org/springframework/roo/addon/test/JUnitStaticEntityMockingControl.aj-template
https://fisheye.springsource.org/browse/spring-roo/trunk/addon-test/src/main/resources/org/springframework/roo/addon/test/MockStaticEntityMethods.java-template
Please see the following Jira issues for background on this feature and key considerations:
https://jira.springsource.org/browse/ROO-92
https://jira.springsource.org/browse/ROO-202
https://jira.springsource.org/browse/ROO-272
Once this functionality has been added to Spring Framework, I will modify the Roo usage accordingly (as is being tracked in ROO-314).
Issue Links:
The text was updated successfully, but these errors were encountered: