Search code examples
testingclojureleiningen

idiomatic path for leiningen test data


By convention, where is data accompanying test typically stored in Leiningen projects?

Some possibilities include: <project_name>/test/<project_name>/data/, <project_name>/test/<project_name>/, or <project_name>/test/data/.

Please list sources of information or reasons behind your argument.


Solution

  • In terms of directory structure:

    • With "src/main-style" directory tree, where your main Clojure source lives under src/main/clojure and your tests under src/test/clojure, I would place test data under src/test/resources.

    • With "src-style" directory tree, where your main Clojure source lives under src and your tests under test, I would place test data under dev-resources or test-resources.

    In either case, I would add the appropriate resources directory to :resources for the :dev and/or :test profiles (except "dev-resources" is actually the default path, so nothing needs to be added if you go with it):

    (defproject … …
      :profiles {:dev {:resources ["src/test/resources"]
                       … …}
                 … …}
      … …)