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

I have a class that uses JSNI to retrieve JSON data stored on the main page:

protected native JsArray<JsonModel> getModels() /*-{ return $wnd.jsonData; }-*/; 

This method is called, and the data is then translated and processed in another way. How should I unit test this class, since I cannot create an instance (or, it would seem, a layout?) Of JsArray?

What is the best way for JSNI unit test methods?

+4
source share
1 answer

The front-end approach is the best approach, and not necessarily brute force. As for the problem of actually testing the method - well, if it just reads from $ wnd.jsonData, there is no use in testing the method. You better write a server-side test that confirms that you have the correct data on the main page.

If you really have logic in your own method, you'd better write a test case of selenium / jsunit.

+3
source

Source: https://habr.com/ru/post/1305518/


All Articles