JMockit compatible with GWTTestCase?

122 views
Skip to first unread message

James Scott

unread,
Dec 28, 2012, 3:15:14 PM12/28/12
to google-we...@googlegroups.com
Hello all-

I'm trying to use JMockit in a GWTTestCase (JUnit 3, for what it's worth) and I'm not having any luck. I have jmockit.jar on my classpath for the test, but when I run it, I get this error message:

[ERROR] Line 50: No source code is available for type mockit.NonStrictExpectations; did you forget to inherit a required module?

Line 50 is where I have my NonStrictExpectations declared in my test case. Right now, it's empty.

I tried TRACE-level logging of the unit test run in Eclipse, and I get similar "no source code available" errors for other classes in the application GWT client code, but those are not under test and not in the same module as the code under test, so I don't think those are interfering.

My classpath includes my Eclipse output dir, GWT jars, jmockit.jar and junit.jar. Is there something else that should be in the classpath?

Thanks,

JLS

Jens

unread,
Dec 28, 2012, 9:02:06 PM12/28/12
to google-we...@googlegroups.com
Its not compatible. Why do you need to mock things in a GWTTestCase? You normally do it in an ordinary JUnit Test to mock out classes that use GWT.create() or JSNI.

-- J.

Thomas Broyer

unread,
Dec 31, 2012, 1:34:02 PM12/31/12
to google-we...@googlegroups.com
There are very few GWT-compatible mocking tools. Actually I know only one, inspired by EasyMock and made by Googlers: https://code.google.com/p/easy-gwt-mock/
An alternative is to "mock GWT" so you can avoid using a GWTTestCase, and thus use the mocking tool you want (including JMockit): https://github.com/gwt-test-utils/gwt-test-utils
But I'm doing things like Jens suggest: abstract GWT-only classes (views) behind interfaces that can easily be mocked, so that a GWTTestCase is not necessary to unittest the business and/or presentation logic.
Reply all
Reply to author
Forward
0 new messages