Wednesday, May 4, 2016

Re: GWT unit tests along with JsInterop and external javascript

How are you loading the JS script into the page? Keep in mind that GWTTestCase doesn't use your HTML host page; you have to use ScriptInjector in GWTTestCase.

On Tuesday, May 3, 2016 at 12:57:44 PM UTC+2, ateletin wrote:
My test case is simple, but it's not working.
I have an external .js file containing an object, Person, which has 2
fields, firstName and lastName, and a method, getFullName. It also have a
constructor that initialize those 2 fields.

I have created a java object Person which is annotated with
@JsInterop(isNative=true, namespace="...", name=Person).

My test case is to create a person and to ask for its full name:
Person pilot = new Person("Kimi", "Raikkonen");
assertTrue(person.getFullName().equals("Kimi Raikkonen"));

The problem is that the Person pilot is not initialized correctly and the
method getFullName() couldn't be found. Neither the fields doesn't exist in
pilot object..

Note that this happens ONLY at GWT Unit Test running, and NOT when I run my
application normally; at normal running, it works as expected.

Have someone did unit test for gwt using jsinterop and external js? Is there
something that I've missed?

Thank you.



--
View this message in context: http://google-web-toolkit.2317884.n4.nabble.com/GWT-unit-tests-along-with-JsInterop-and-external-javascript-tp15739.html
Sent from the Google Web Toolkit mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment