Reputation: 6417
my question is: how can I access dom elements from gwt unit testcase?
I have only a static html with a link:
<a href="#" id="my_button">jjj</a>
When I do
public void testButton() {
Element elm = Document.get().getElementById("my_button");
assertNotNull(elm);
}
I'll get a RuntimeException (test failed) because elm
is null
.
What's wrong? Am I missing any init call...?
Upvotes: 0
Views: 161
Reputation: 64541
Unit tests in GWT do not use your application's host page; they use a (or junit-standards.html) from the com.google.gwt.junit.JUnit
module, which is almost empty.
You have to "create" the environment your test runs in (in gwtSetup
or at the beginning of your test method).
Upvotes: 1