0

私はテストの初心者です。アプリを開発するときは、アプリをテストするために Robotium を使用しますが、今度は Util クラスのメンバーであるいくつかの関数をテストしたいと思います。例えば:

public static boolean internetConnection(Context context) {
    ConnectivityManager conMgr = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo i = conMgr.getActiveNetworkInfo();
    if (i == null)
        return false;
    else if (!i.isConnected())
        return false;
    else if (!i.isAvailable())
        return false;

    return true;
}

または例:

    public static boolean isTabletDevice(Context context) {
    if (android.os.Build.VERSION.SDK_INT >= 11) { // honeycomb
        // test screen size, use reflection because isLayoutSizeAtLeast is
        // only available since 11
        Configuration con = context.getResources().getConfiguration();
        try {
            Method mIsLayoutSizeAtLeast = con.getClass().getMethod(
                    "isLayoutSizeAtLeast", int.class);
            Boolean r = (Boolean) mIsLayoutSizeAtLeast.invoke(con,
                    0x00000004); // Configuration.SCREENLAYOUT_SIZE_XLARGE
            return r;
        } catch (Exception x) {
            x.printStackTrace();
            return false;
        }
    }
    return false;
}

これらの機能をテストするにはどうすればよいですか?

どうもありがとう!!

4

1 に答える 1