We have a ServletFilter that we want to test with Spock and test calls on the HttpServletRequest.
The following code throws java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/http/Cookie
def "some meaningless test"(){ given: HttpServletRequest servletRequest = Mock(HttpServletRequest) when: 1+1 then: true }
The JavaEE 5 API (and therefore the servlet API) is in the classpath. The Spock version is 0.6- groovy -1.8.
How will we do it right? He works with Mokito, but we will lose Spock, mocking awesomeness.
Editing: We know about Grails and Spring built-in mocking capabilities for Servlet stuff, we just wanted to know if there is a way to do this with Spock's mockery. Otherwise, you will have a mixture of mocking customization methods ...
source share