Leiningen missing test resources?
Asked Answered
D

1

5

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

Decemvir answered 2/11, 2015 at 16:44 Comment(0)
S
10

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.

Slatternly answered 2/11, 2015 at 20:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.