错误 java.lang.RuntimeException:存根!在 Android 中进行 Fitnesse 测试 [英] Error java.lang.RuntimeException: Stub! in Android with Fitnesse testing

查看:15
本文介绍了错误 java.lang.RuntimeException:存根!在 Android 中进行 Fitnesse 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Fitnesse 框架创建一个测试装置,并且我想测试一个从服务器(RESTFUL 服务)检索数据的函数.我的测试用例很简单:

I'm trying to create a test fixture using Fitnesse framework, and I want to test a function which retrieves data from a server (RESTFUL service). My test case is very simple:

public class FriendListActivityFixture extends ColumnFixture {
    public int URL;
    public String test() {
    JSONArray array = JsonHelper.getJsonArrayFromUrl("http://107.22.209.62/android/get_users.php");
    return array.toString();
    }
}

public static JSONArray getJsonArrayFromUrl(String url) {
        InputStream input = null;
        String result = "";
        JSONArray jsonArray = null;
        try {
            HttpClient httpclient = CustomHttpClient.getHttpClient();
            HttpPost httppost = new HttpPost(url);
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            input = entity.getContent();
        }
        catch (Exception e) {
            Log.e(TAG + ".getJsonArrayFromUrl(String url)", "Error in http connection " + e.toString()); 
        }

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(input, "iso-8859-1"), 8);
            StringBuilder content = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                content.append(line + "
");
            }
            input.close();
            result = content.toString();
        }
        catch (Exception e) {
            Log.e(TAG + ".getJsonArrayFromUrl(String url)", "Error parsing result " + e.toString());
        }

        try {
            jsonArray = new JSONArray(result);
        }
        catch (JSONException e) {
            Log.e(TAG + "getJsonArrayFromUrl(String url)", "Error converting data " + e.toString());
        }
        return jsonArray;
    }

这里是 Fitnesse 测试页面:!path fitnesse.jar

And here is the Fitnesse test page:!path fitnesse.jar

!path C:Program Files (x86)Androidandroid-sdkplatformsandroid-10android.jar
!path C:UserschangitSpotrSpotrinclasses

!|com.csun.spotr.fitnesse.FriendListActivityFixture|
|URL|test?|
|0|"wwa"|

由于它只是一个演示,我的测试目前可能看起来有点傻.不幸的是,我不断收到这些错误:

Since it's just a demo, my test might look a bit silly at the moment. Unfortunately, I keep getting these errors:

java.lang.RuntimeException: Stub!
    at android.util.Log.e(Log.java:15)
    at com.csun.spotr.util.JsonHelper.getJsonArrayFromUrl(JsonHelper.java:75)
    at com.csun.spotr.fitnesse.FriendListActivityFixture.test(FriendListActivityFixture.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at fit.TypeAdapter.invoke(TypeAdapter.java:109)
    at fit.TypeAdapter.get(TypeAdapter.java:97)
    at fit.Fixture$CellComparator.compareCellToResult(Fixture.java:371)
    at fit.Fixture$CellComparator.access$100(Fixture.java:357)
    at fit.Fixture.compareCellToResult(Fixture.java:299)
    at fit.Fixture.check(Fixture.java:295)
    at fit.ColumnFixture.check(ColumnFixture.java:51)
    at fit.Binding$QueryBinding.doCell(Binding.java:215)
    at fit.ColumnFixture.doCell(ColumnFixture.java:37)
    at fit.Fixture.doCells(Fixture.java:171)
    at fit.Fixture.doRow(Fixture.java:165)
    at fit.ColumnFixture.doRow(ColumnFixture.java:25)
    at fit.Fixture.doRows(Fixture.java:159)
    at fit.ColumnFixture.doRows(ColumnFixture.java:18)
    at fit.Fixture.doTable(Fixture.java:153)
    at fit.Fixture.interpretTables(Fixture.java:99)
    at fit.Fixture.doTables(Fixture.java:79)
    at fit.FitServer.process(FitServer.java:81)
    at fit.FitServer.run(FitServer.java:56)
    at fit.FitServer.main(FitServer.java:41)

我不知道它在告诉我什么?我编写了其他测试方法,如 add(), substract(),一切正常.我想知道这个错误是否涉及在主线程上运行一个长任务?有什么想法吗?

And I have no idea what is it telling me? I wrote other testing method like add(), substract(), everything worked fine. I wonder does this error involve running a long task on the main thread? Any idea?

推荐答案

android.jar 只包含类的存根实现.它为您提供了构建应用的方法,一旦您拥有 APK,您必须在 Android 设备或模拟器上运行它.

android.jar contains only stub implementation of the classes. It provides the means for you app to build, once you have your APK you must run it on an android device or emulator.

如果我没记错的话,您正试图在主机的 JVM 上运行.

If I'm not wrong you are trying to run on host's JVM.

这篇关于错误 java.lang.RuntimeException:存根!在 Android 中进行 Fitnesse 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆