-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I've been able to test Widgets with JUnit in a project I'm working on.
I'm able to make widgets, see that they respond to external events
(notifications about state they observe, or event types they're
subscribed to via an EventBus, that sort of thing), and even send UI
events to them:
final MyWidget myWidget = new MyWidget(...);
myWidget.someButton.fireEvent(new ClickEvent() { });
//assert that the right things happened
The anonymous subclass of ClickEvent feels a little hacky, but it works
for us because our widgets (for the most part) just care that they got
clicked, they don't care about x and y coords, etc etc.
Writing the tests was relatively straightforward, but getting them to
run as part of a Maven build took some doing. A pom with all the
necessary incantations is here:
https://open.med.harvard.edu/svn/shrine/trunk/code/webclient/pom.xml
I don't know if that's minimal or not; I started with what was generated
by the gwt-maven-plugin, and tweaked the pom until it did what I wanted.
:/ We use a TestSuite (ugh) and follow the naming conventions for test
classes and suites recommended by the gwt-maven-plugin docs.
On 04/24/2012 04:50 PM, King_V wrote:
> Ok, I found some old messages (several years old) that says this
> cannot be done.
>
> However, when I look at:
> https://developers.google.com/web-toolkit/doc/latest/DevGuideTesting#DevGuideJUnitSetUp
>
> this seems to imply that you can actually test GUI items on a browser
> with such tests. I might well be completely misinterpreting what it's
> there for, though.
>
> However, I'm baffled as to how to do so.
>
> For example, I might normally put MyWidget into the RootPanel as
> follows:
>
> RootPanel.get().add(new MyWidget("Some text here"));
>
>
> But how would I do this in a JUnit test case / GWTTestCase?
>
> Thanks.
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEARECAAYFAk+XRSEACgkQ0GFaTS4nYxviVACeMqLdXljCkWI3lrS9tCDBulvF
pqkAn24TZuVGsdOccZTBDCWlGsGjpMi/
=G4pS
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment