Gradle: JUnitでResourcesフォルダのファイルが読めない場合

ハマったのでメモ。

リンクの通りだが、自分の場合は↓を行うことで解消。
※同じコードで動かないから設定周りだとは思ったけど・・

In IntelliJ:

  1. Right-click your test/resources (or test/java/resources) directory
  2. Select the "Mark Directory as..." sub-menu
  3. Select "Test Resources Root"
  4. This directory will appear with a decorator graphic symbolizing that it is in the classpath

In Eclipse:

  1. Go to "Run->Run configurations..." (in case of debug "Run->Debug configurations...")
  2. Open Run (Debug) configuration which you use
  3. Open "Classpath" tab
  4. Select "User Entries" and click "Advanced..." on the right
  5. In the opened window select "Add folder", point to your src/test/resources
  6. This folder will appear under "User entries", then you should move it up to make it the first on your classpath

参考