开发者

Test JsonUtils in GWTTestCase

开发者 https://www.devze.com 2023-03-30 02:37 出处:网络
I want to create some testcase to see if my JSON parsing classes work correct. Therefore I want to instantiate them with a JavaScript object which I create form a JSON String throw the JsonUtils.

I want to create some testcase to see if my JSON parsing classes work correct. Therefore I want to instantiate them with a JavaScript object which I create form a JSON String throw the JsonUtils.

My problem now is that, JsonUtils is a native method, so there is now source code available for it, during testing.

Is ther开发者_开发百科e a possibility to built GwtTestCases which include native methods?


Ok, after writting the question I got some new ideas to google and found this article: UnsatisfiedLinkError in GWTTestCase. Options.

So apperently you just cant use native methods in the GWTTestCase constructur, but you can use them inside the test function.

Example illeagal:

JSWidgetBasic jswb;
public JSWidgetBasicTest() {
    String s_jswb = "{\"zzzz\":\"type\"}";
    jswb = JsonUtils.safeEval(s_jswb).cast();
}

public void testWidgetType() {
    assert (jswb.getZZZZ().compareTo("type") == 0);
}

but this is allowed

public JSWidgetBasicTest() {
}

public void testWidgetType() {
    String s_jswb = "{\"zzzz\":\"type\"}";
    JSWidgetBasic jswb = JsonUtils.safeEval(s_jswb).cast();

    assert (jswb.getZZZZ().compareTo("type") == 0);
}

Hope this helps someboedy, cause I wasted a few hours finding it....

0

精彩评论

暂无评论...
验证码 换一张
取 消