Skip to content
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

How to run rcf tests in a polylith project? #62

Open
ieugen opened this issue Aug 25, 2022 · 5 comments
Open

How to run rcf tests in a polylith project? #62

ieugen opened this issue Aug 25, 2022 · 5 comments

Comments

@ieugen
Copy link
Contributor

ieugen commented Aug 25, 2022

I would like to run rcf tests (from my src/ directories) of polylith bricks.

I run tests with clojure -Srepro -M:poly test .
Right now tests are not run, probably because the (hyperfiddle.rcf/enable!) is not run from development/src/user.clj

https://polylith.gitbook.io/poly/workflow/testing

I will probably create+link this to the polylith project so we can figure out and document this feature.

@ieugen
Copy link
Contributor Author

ieugen commented Aug 25, 2022

So, after some discussions and investigations, I found out the following: https://clojurians.slack.com/archives/C013B7MQHJQ/p1661457088307879 .

We can use test setup and tear-down to call rcf/enable! https://polylith.gitbook.io/poly/workflow/testing#test-setup-and-teardown .

(ns foo.test-setup
  (:require [hyperfiddle.rcf]))

(defn setup
  "Enable rcf tests https://github.com/hyperfiddle/rcf#usage"
  [project-name]
  (println "Setup hyperfiddle.rcf in project" project-name)
  (hyperfiddle.rcf/enable!))

in workspace.edn

 :projects {
            "app" {:alias "app"
                   :test {:setup-fn foo.test-setup/setup}}

Unfortunately, this does not work for tests under src/ .
It does work for tests under test/ .

Trying to figure out why.

@ieugen
Copy link
Contributor Author

ieugen commented Aug 25, 2022

So in polylith, test runner (polylith-kaocha) only considers files that end with _test . and only under test/ .
I added a test file on src/ and another file without test on test/ .
Only files ending in _test under test/ work.
I wonder if this is something I can change with kaocha config.

@ieugen
Copy link
Contributor Author

ieugen commented Aug 29, 2022

Polylith projects can run RCF tests normally, but they require passing the JVM option -Dhyperfiddle.rcf.generate-tests=true to the poly tool.

In normal projects, this means adding :jvm-opts to ./deps.edn like so:

:aliases { 
  :poly {:main-opts ["-m" "polylith.clj.core.poly-cli.core"]
         ;; REDACTED
         :jvm-opts ["-Dhyperfiddle.rcf.generate-tests=true"]
         :extra-deps {polylith/clj-poly REDACTED
                             polylith-kaocha/test-runner REDACTED }}

@ieugen
Copy link
Contributor Author

ieugen commented Aug 29, 2022

See https://github.com/ieugen/poly-rcf as well.
It works with some caveats.

For src/ tests we need to add src/ to :test :extra-paths

@licht1stein
Copy link

Thanks @ieugen your solution works on my project!

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

2 participants