rcf icon indicating copy to clipboard operation
rcf copied to clipboard

How to use RCF with leiningen

Open dustingetz opened this issue 2 years ago • 5 comments

Question is: "Basically just be able to use RCF with lein. It would be great if i can 'lein test' and it works."

dustingetz avatar Apr 24 '22 20:04 dustingetz

Solution from slack: https://clojurians.slack.com/archives/C7Q9GSHFV/p1650824587456189

; project.clj
:test-paths ["test"]
  :profiles {
             :test {:jvm-opts ["-Dhyperfiddle.rcf.generate-tests=true"]
                    :aliases {"run-tests" ["run" "-m" "app.core-test/run-tests" :project/test-paths]}}
             }

;app_test.clj
(ns app.core-test
  (:require [clojure.test :as test]
            [app.config]))

(defn run-tests [args]
  (test/run-tests 'app.config))

;how to run it (terminal)
lein with-profile test run-tests

; references
; https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md#not-writing-a-plugin-%E6%97%A0%E4%B8%BA
; https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md

I'd be happy to learn about better/cleaner way to do this. At the moment this approach works for my needs.

Thanks for sharing this!

StankovicMarko avatar Apr 24 '22 20:04 StankovicMarko

A minimal project.clj:

(defproject my/project "0.0.0"
  :dependencies [[org.clojure/clojure "1.10.3"]]
  :profiles {:test {:dependencies [[com.hyperfiddle/rcf "20220405"]]
                    :jvm-opts ["-Dhyperfiddle.rcf.generate-tests=true"]}})

Then run lein test

If you have tests forms in your src folder:

(defproject my/project "0.0.0"
  :dependencies [[org.clojure/clojure "1.10.3"]
                 [com.hyperfiddle/rcf "20220405"]]
  :profiles {:test {:jvm-opts ["-Dhyperfiddle.rcf.generate-tests=true"]
                    :test-paths ["test" "src"]}})

ggeoffrey avatar Apr 25 '22 08:04 ggeoffrey

Oh wow, it's obvious now. Thanks a lot :)

StankovicMarko avatar Apr 25 '22 08:04 StankovicMarko

I would love for this to be documented for newbies like me :)

ieugen avatar Aug 11 '22 21:08 ieugen

Reopening to add to readme

dustingetz avatar Aug 12 '22 20:08 dustingetz