junit テストに使用する eclipse プラグイン プロジェクトと対応するフラグメント プロジェクトを作成しました。
フラグメントでは、プラグイン プロジェクトを「ホスト プラグイン」として指定します。さらに、build.properties ペインで次のように指定します。
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
my.properties
my.properties は、フラグメント プロジェクトのルートにあるファイルです。次に、次のように my.properties ファイルをロードしようとするテストを作成しました。
Properties properties = new Properties();
InputStream istream = this.getClass().getClassLoader()
.getResourceAsStream("my.properties");
try {
properties.load(istream);
} catch (IOException e) {
e.printStackTrace();
}
しかしistream
null であり、try ブロックで load を呼び出すと、テストは NullPointerException で失敗します。
ホストプラグインで同じことをしようとしましたが、正常に動作します。Junit を使用しているときに PDE フラグメントのリソースを読み取れない理由について何か考えはありますか?