Mockito for HttpServletRequest

85 views
Skip to first unread message

richard wang

unread,
Jun 5, 2021, 7:04:06 AM6/5/21
to mockito
Hi Friends, 

We are testing with mockito with servletrequest, however, it keeps showing the error:

Mockito cannot mock this class: org.springframework.mock.web.MockhttpServletRequest.  The test ran fine in ecliple, but not in maven build: 

Can anyone give some hints?

thanks very much

R

Brice Dutheil

unread,
Jun 7, 2021, 4:58:34 AM6/7/21
to moc...@googlegroups.com
Hi Richard,

I don't know what could be the cause here without a proper bug report. But when I was using Eclipse and had this combination (Eclipse + Maven), I remember having trouble running tests in maven.

The reason is that the Eclipse compiler does things a bit differently than the JDK compiler, as Eclipse compiler is constantly running it overwrites classes compiled by javac, and when the tests run it might lead to inconsistent/incompatible bytecode. The only workaround was to terminate Eclipse and do a `mvn clean test`.


Hope that helps.

Cheers
-- Brice


--
You received this message because you are subscribed to the Google Groups "mockito" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockito+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mockito/d3dc6024-5ea6-42ab-8670-6a3f98c9946en%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages