Skip to content

Testing with static resources #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
symbiont-sean-lyons opened this issue May 5, 2021 · 0 comments
Open

Testing with static resources #58

symbiont-sean-lyons opened this issue May 5, 2021 · 0 comments

Comments

@symbiont-sean-lyons
Copy link

symbiont-sean-lyons commented May 5, 2021

It does not look like clojure_test supports attributes resources or data the way that java rules do. Any advice on how to support a use-case where my unit tests depend on static resources?

My project is structured like so

test/
|- my_test.clj
|- testdata/
|--- data.edn

and I just want to be able to access my .edn file from my_test.clj, for example (slurp "testdata/data.edn").

I tried to exposing the testdata as a file group, but clojure_test cannot depend on something that does not provide JavaInfo.

Additionally, I tried to package my testdata in a java library like so

--- test/BUILD
 clojure_test(
     name = "test",
     deps = [
         "//test/testdata/data",
     ],
     srcs = [
         "my_test.clj",
     ],
 )

--- testdata/BUILD
 java_library(
     name = "data",
     resources = glob(["*.edn"]),
     visibility = ["//visibility:public"],
 )

I would not be surprised if the jar approach makes no sense, I just gave it a shot :)

Appreciate any advice you can offer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant