Fork me on GitHub
#testing
<
2022-04-25
>
nottmey09:04:40

Hi, one question regarding https://github.com/hyperfiddle/rcf and IntelliJ Idea (with Cursive): How do I configure the Run/Debug Config, so that I can test the generated tests with the intellij tooling? Edit: Basically I’m asking how to configure {:aliases {:test {:jvm-opts ["-Dhyperfiddle.rcf.generate-tests=true"]}}} + clj -M:test -e "(require 'example)(clojure.test/run-tests 'example)" as clojure.test execution

Dustin Getz12:04:13

Hi Malte, thank you for trying RCF! We don't know what this is: "so that I can test the generated tests with the intellij tooling" Can you take a Loom video of your old workflow that you desire to integrate with? So we can understand concretely, exactly what it is you want to do https://www.loom.com/ - a fast and easy way to record short videos and share a link in a couple clicks

Dustin Getz13:04:40

1-2 screenshots would also probably suffice

nottmey13:04:42

Hi Dustin, oh good question. I’ll try to capture a better example later. For now I found this: Basically I’m used to the “clojure.test” Test Runner here: https://cursive-ide.com/userguide/testing.html I’m wondering what to input in picture one and two to get testing feedback displayed similar to picture three and possibly four

👀 1
nottmey20:04:30

I think I don’t need to record a video. The question boils down to this: I have deps.edn

{:paths   ["src"]
 :deps    {com.datomic/client-api  {:mvn/version "1.0.58"}
           com.hyperfiddle/rcf     {:mvn/version "20220405"}
           com.walmartlabs/lacinia {:mvn/version "1.1"}
           org.clojure/clojure     {:mvn/version "1.11.1"}}
 :aliases {:repl     {:extra-paths ["dev"]}
           :test     {:extra-paths ["test"]
                      :extra-deps  {io.github.cognitect-labs/test-runner
                                    {:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
                      :main-opts   ["-m" "cognitect.test-runner"]
                      :exec-fn     cognitect.test-runner.api/test}
           ; clj -M:test-rcf -e "(require 'datomic-lacinia.utils)(clojure.test/run-tests 'datomic-lacinia.utils)"
           :test-rcf {:jvm-opts  ["-Dhyperfiddle.rcf.generate-tests=true"]}}}
How can I configure alias :test to also run the RCF tests?

Dustin Getz20:04:43

You can put the JVM flag to generate clojure.test/deftests under :test but the problem is if you start moving or renaming tests at the REPL you will probably dangle old tests, because RCF tests do not have identity (they aren't named, clojure.test tests have names)

Dustin Getz20:04:06

We are planning to have that capability but no ETA, our next technical alpha needs to be released first

👌 1
nottmey21:04:30

hmm, I don’t know whether that would be an issue for me (since it’s single runs of clj -M:test ) when I put :jvm-opts ["-Dhyperfiddle.rcf.generate-tests=true"] into :test it doesn’t do anything because the testrunner ist only using the test dir. but when I provide src as test dir with

✘1 ➜ clj -M:test -d src                                                                              

Running tests in #{"src"}

Testing user

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
it doesn’t find the rcf tests :thinking_face:

Dustin Getz21:04:24

I think it means the namespaces aren't loaded, are you in control of the command line incantation?

Dustin Getz21:04:53

e.g. i would expect this to work clj -M:test"(require 'datomic-lacinia.utils)(clojure.test/run-tests 'datomic-lacinia.utils)"

nottmey21:04:39

sadly that doesn’t work even with -e variations But yes, I see why cognitect.test-runner is not picking up the RCF tests. The namespaces are not evaluated/loaded yet, and that’s why the macro expansion did not happen yet. (Well I think that whats going on.)

nottmey21:04:02

success!

➜ clj -M:test -d src -n datomic-lacinia.utils                                                            

Running tests in #{"src"}

Testing datomic-lacinia.utils
✅✅✅✅✅.✅✅✅✅✅✅.✅✅✅✅✅.
Ran 3 tests containing 16 assertions.
0 failures, 0 errors.

nottmey21:04:49

ok, perfect, namespace regex does work too

➜ clj -M:test -d src -r "datomic-lacinia.*"

Running tests in #{"src"}

Testing datomic-lacinia.graphql
✅.✅✅✅.✅.
Testing datomic-lacinia.types
✅✅✅✅.✅✅✅.
Testing datomic-lacinia.utils
✅✅✅✅✅.✅✅✅✅✅✅.✅✅✅✅✅.
Ran 8 tests containing 28 assertions.
0 failures, 0 errors.

Dustin Getz21:04:08

Great - do you have it working in Cursive now?

nottmey21:04:13

sadly no, but clj -M:test works now with all tests

{:paths   ["src"]
 :deps    {com.datomic/client-api  {:mvn/version "1.0.58"}
           com.hyperfiddle/rcf     {:mvn/version "20220405"}
           com.walmartlabs/lacinia {:mvn/version "1.1"}
           org.clojure/clojure     {:mvn/version "1.11.1"}}
 :aliases {:repl     {:extra-paths ["dev"]}
           :test     {:extra-paths ["test"]
                      :extra-deps  {io.github.cognitect-labs/test-runner
                                    {:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
                      :main-opts   ["-m" "cognitect.test-runner" "-d" "src" "-d" "test" "-r" "datomic-lacinia.*"]
                      :exec-fn     cognitect.test-runner.api/test
                      :jvm-opts    ["-Dhyperfiddle.rcf.generate-tests=true"]}}}
➜ clj -M:test

Running tests in #{"src" "test"}

Testing datomic-lacinia.graphql
✅.✅✅✅.✅.
Testing datomic-lacinia.types
✅✅✅✅.✅✅✅.
Testing datomic-lacinia.utils
✅✅✅✅✅.✅✅✅✅✅✅.✅✅✅✅✅.
Testing datomic-lacinia.schema-test
.
Ran 9 tests containing 29 assertions.
0 failures, 0 errors.

nottmey21:04:31

cursive still just picks up the normal tests

nottmey21:04:53

I guess it overrides some of the deps alias config 😕

Dustin Getz21:04:37

Does the "parameters" field pass through to CLJ internally?

nottmey21:04:02

I guess I ask in #cursive whether they have any clues 😄 Thank you for helping and following along! 🙇