On Wednesday, December 12, 2012 5:02:35 PM UTC+1, bvt wrote:
>
> I'm attempting to write a unit test for a presenter/activity which makes a 
> request via RequestBuilder and reads this into a JavaScript overlay type. I 
> would like to create a mock instantiation of this overlay type class for 
> testing purposes, but it doesn't seem this is possible. What is the normal 
> approach for writing unit tests involving RequestBuilder and overlay types?
>

Either you abstract it behind some interface that you can mock, or you'll 
have to use a GWTTestCase.
 

> I'd really love to use an ordinary JUnit test case if possible. Is this 
> possible or do I have to use GWTTestCase? Either way, I'm not sure how to 
> handle the actual request. There is no guarantee the service that is 
> getting called via RequestBuilder will be available at build time, so I'd 
> really like to mock this somehow.
>

You can provide a "mock servlet" at testing time: add a <servlet/> element 
to the gwt.xml used by your GWTTestCase (the one whose name is returned by 
getModuleName; it's generally either your "normal" module-under-test or a 
test-specific module that <inherits/> your module-under-test). More info 
about that <servlet/> element can be found at 
https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideModuleXml

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/3KVHzXKDy2oJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to