GWT: Best practice for unit testing / mocking JSNI methods?

前端 未结 1 1067
执念已碎
执念已碎 2021-01-20 01:03

I have a class which uses JSNI to retrieve JSON data stored in the host page:

protected native JsArray getModels() /*-{
    return $wnd.json         


        
相关标签:
1条回答
  • 2021-01-20 01:38

    The interface approach is the best approach, and not necessarily an overkill. As to the problem of actually testing the method - well, if it is just reading from $wnd.jsonData, there isn't any merit in testing the method. You are better off writing a server side test that confirms you have the right data in the host page.

    If you really have some logic in a native method, you are better off writing a selenium/jsunit test case.

    0 讨论(0)
提交回复
热议问题