Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leiningen missing test resources?

Leiningen provides a default directory for 'main' code, main resources, and test code, but nothing for test resources.

Coming from a maven background this is something I'd expect.

In that case, where should test resources live? Or a larger question, what's the philosophical reason why it wouldn't need a test resources directory

like image 263
Roy Truelove Avatar asked Nov 02 '15 16:11

Roy Truelove


1 Answers

Test resources in Leiningen are managed using profiles. To set up a directory with test resources, you would add its path to the :resource-paths property of the :test profile (to make it available only to the test task) or :dev profile (to make it available to all dev tasks, e.g. test, run, repl, etc.)

Sample project.clj for a Maven-like project structure:

(defproject myproject "0.0.1-SNAPSHOT"
  :source-paths ["src/main/clj"]
  :test-paths ["src/test/clj"]
  :resource-paths ["src/main/resources"]
  :dev {:resource-paths ["src/test/resources"]})

When the :dev profile is active, its :resource-paths values are merged with the :resource-paths from the base project, giving you what you're looking for.

See the Leiningen docs for more information on profiles.

like image 62
Alex Avatar answered Oct 22 '22 04:10

Alex