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

Support using a custom test runner & reporter #188

Closed
Pancia opened this issue Mar 4, 2021 · 9 comments
Closed

Support using a custom test runner & reporter #188

Pancia opened this issue Mar 4, 2021 · 9 comments
Labels
client-clojure contributable Doesn't require large architectural changes, anyone can contribute :) enhancement New feature or request

Comments

@Pancia
Copy link

Pancia commented Mar 4, 2021

I would like to be able to use a different test runner & reporter, in this case kaocha.
It's documentation https://cljdoc.org/d/lambdaisland/kaocha/1.0.732/doc/5-running-kaocha-from-the-repl tells you what functions are available, and I can confirm that evaluating manually a deftest wrapped in a kaocha.repl/run does what i want.

Alternatively, I would be content with a way to wrap the current test running with a (binding [t/report X] ,,,), where X is a different clojure.test/report function, eg: kaocha.report/documentation.

@Olical Olical added client-clojure enhancement New feature or request contributable Doesn't require large architectural changes, anyone can contribute :) labels Mar 9, 2021
@alysbrooks
Copy link

I help maintain Kaocha and love Conjure, so if you need anything from our end, feel free to let me know!

@Olical
Copy link
Owner

Olical commented Mar 29, 2021

Probably needs some polish, but this is working on the develop branch! Feedback appreciated!

; --------------------------------------------------------------------------------
; run-ns-tests: dev.sandbox
; [(F�[m.)]
; Randomized with --seed 348065898
; 
; FAIL�[m in dev.sandbox/test-b (NO_SOURCE_FILE:61)
; bar
; Expected:
;   9
; Actual:
;   -9 +10
; 2 tests, 2 assertions, 1 failures.�[m
#:kaocha.result{:count 2, :pass 1, :error 0, :fail 1, :pending 0}

With the following config (requires translating to viml, I used nvim-local-fennel)...

(module conjure-local-fennel-config
  {require {nvim aniseed.nvim}})

(set nvim.g.conjure#client#clojure#nrepl#test#runner_namespace "kaocha.repl")
(set nvim.g.conjure#client#clojure#nrepl#test#all_fn "run")
(set nvim.g.conjure#client#clojure#nrepl#test#ns_fn "run")
(set nvim.g.conjure#client#clojure#nrepl#test#var_fn "run")
(set nvim.g.conjure#client#clojure#nrepl#test#var_prefix "")
(set nvim.g.conjure#client#clojure#nrepl#test#var_suffix "")

@Olical
Copy link
Owner

Olical commented Mar 31, 2021

So what do people think about leaving the current test mappings as invoking clojure.test and instead adding integration to start kaocha from within a Conjure nREPL connection? So relying on the file watching etc rather than invoking individual tests through mappings?

Or are both routes useful in different scenarios? I was originally leaning towards the current experiment on develop where you can invoke specific tests through kaocha, but using it as a clojure.test replacement. But maybe they have totally different strategies and can be used alongside each other in practice.

I'm also reworking it so you can set one config option, g:conjure#client#clojure#nrepl#test#runner = "kaocha" and that configures everything for you.

@Olical
Copy link
Owner

Olical commented Mar 31, 2021

Fixed things up a little so I'm turning off ANSI colours while running tests through kaocha and massively simplified the usage. If you wanna try this out, set this in your config!

let g:conjure#client#clojure#nrepl#test#runner = "kaocha"

I'd love some feedback on this 😄 if it's already scratching the itch I'll probably move forward with releasing it this week (along with all the other fixes on develop). Enjoy!

@Pancia
Copy link
Author

Pancia commented Mar 31, 2021

So what do people think about leaving the current test mappings as invoking clojure.test and instead adding integration to start kaocha from within a Conjure nREPL connection? So relying on the file watching etc rather than invoking individual tests through mappings?

Personally, I already run kaocha watch in a separate terminal, and have recently found a lot of value in running a specific test without having kaocha reload the entire project (which takes ~10-20 seconds).

@alysbrooks
Copy link

I agree with @Pancia, although starting Kaocha through the REPL could be useful sometimes, especially for people who don't use --watch. Either way, it looks like you'll be using the existing nREPL connection, which will also save on JVM and Clojure start-up.

@Olical
Copy link
Owner

Olical commented Apr 1, 2021

Thanks for the feedback! I'll stick with what I have for now then, it allows you to run your tests with kaocha instead of clojure.test. Adding a way to launch kaocha with a command can be a future thing if people really want it (but you can also just add a comment in your code that contains the code for this and eval it, I think it's like one form?).

@Olical Olical closed this as completed Apr 1, 2021
@Pancia
Copy link
Author

Pancia commented Apr 1, 2021

I noticed you added :call-suffix "{:kaocha/color? false}", but no way to configure it?
I personally would like to modify it, in my case to {:config-file "tests.local.edn"}, do you see a way to easily support this?

@Olical
Copy link
Owner

Olical commented Apr 1, 2021 via email

BerkeleyTrue pushed a commit to BerkeleyTrue/conjure that referenced this issue May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client-clojure contributable Doesn't require large architectural changes, anyone can contribute :) enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants