プロジェクト

全般

プロフィール

オブジェクトデータの確認

Edit

データのDump

データクラスに格納されたオブジェクトデータをコンソールに出力することができる。

1. データクラスが所属する対象パッケージをセットするためのメンバフィールドを用意する。

private static List PackageList;

2. データクラスが所属する対象パッケージをセットする。

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    PackageList = new ArrayList<String>();
    PackageList.add("car.models.com.data");
}

3. データのDump処理を組み込む。

COMDataDump dump = new COMDataDump();
try {
    dump.setTargetCategoryFromPackage(PackageList);
    Field field = CarContainer.class.getDeclaredField("CarInfoList");  // データクラス内のDumpしたいメンバを指定する。("CarInfoList"の部分)
    dump.dumpData(carContainer, field);                                // データクラスのオブジェクトを指定する。(carContainerの部分)
}
catch (ClassNotFoundException e) {
    e.printStackTrace();
}
catch (IOException e) {
    e.printStackTrace();
}
catch (ArrayIndexOutOfBoundsException e) {
    e.printStackTrace();
}
catch (IllegalArgumentException e) {
    e.printStackTrace();
}
catch (IllegalAccessException e) {
    e.printStackTrace();
}
catch (NoSuchFieldException e) {
    e.printStackTrace();
}
catch (SecurityException e) {
    e.printStackTrace();
}

4. 実行時に、オブジェクトデータがコンソールに出力される。

Edit

img_junit_testcase_006.png (64.2 KB) Delete Redmine Admin, 2016/03/24 02:23

新しいファイル

他の形式にエクスポート: PDF HTML TXT