I've a simple JavaScript:

var ns = {
  Person: function() {
    this.sayHello = function() {
      return 'Hi';

And I used it to test JsInterop annotation `@JsType` in my GWT test. I
injected JS code to
GWTTestCase and tried to retrieve the definition via `@JsType`. However, it
work, it seems that GWT cannot find the method (see Travis CI [1]):

> [INFO] [ERROR] function
@io.mincongh.client.interop.GwtTestJsInterop$Person::sayHello() NOT FOUND,
thisObj: com.google.gwt.dev.shell.JavaObject@43182ce3, methodName:
> [INFO] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
11.342 sec <<< FAILURE!

Actually, my code is pretty simple:

public class GwtTestJsInterop extends GWTTestCase {
  public void gwtSetUp() {
    String js = "var ns = { Person: function() { this.sayHello = function()
{ return 'Hi'; }; } }";

  public String getModuleName() {
    return R.JUNIT_MODULE;

  public void testJsni() {
    assertEquals("Hi", sayHello());

  private native String sayHello() /*-{
    var p = new ns.Person();
    return p.sayHello();

  public void testJsType() {
    Person p = new Person();
    String words = p.sayHello();
    assertEquals("Hi", words);

  @JsType(namespace = "ns", isNative = true)
  private static class Person {
    public native String sayHello();

Note: The 2nd test method, `testJsni()`, runs successfully, so the JS
should be
injected correctly. I also have the flag `generateJsInteropExports` enabled
in the
Maven GWT plugin in the POM [2]. So what am I missing?

I'm using GWT 2.8.2 and Maven GWT plugin 2.8.2. Any help will be

Thank you,
Mincong HUANG

[1]: https://travis-ci.org/mincong-h/learning-gwt/builds/351967694#L754

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+unsubscr...@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.

Reply via email to