Gradle: JUnitでResourcesフォルダのファイルが読めない場合
ハマったのでメモ。
リンクの通りだが、自分の場合は↓を行うことで解消。
※同じコードで動かないから設定周りだとは思ったけど・・
In IntelliJ:
- Right-click your
test/resources
(ortest/java/resources
) directory - Select the
"Mark Directory as..."
sub-menu - Select
"Test Resources Root"
- This directory will appear with a decorator graphic symbolizing that it is in the
classpath
In Eclipse:
- Go to
"Run->Run configurations..."
(in case of debug"Run->Debug configurations..."
) - Open Run (Debug) configuration which you use
- Open
"Classpath"
tab - Select
"User Entries"
and click"Advanced..."
on the right - In the opened window select
"Add folder"
, point to yoursrc/test/resources
- This folder will appear under
"User entries"
, then you should move it up to make it the first on yourclasspath