So, there isn’t at the moment, no, sorry. It’s something I’ve been planning for a while. Generally I assume people use the testing features in lein, boot, gradle or whatever for project-wide tests. That said, this would clearly be very nice to have.
I guess you’re using Gradle, right? Would you want Cursive to just get all test namespaces from a module and run the tests from it?
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/etPan.59278ee7.497dc0f0.51d%40cursive-ide.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/CAPVSbFObcBAS03dCngLB_AzzZXVTzsLZvQ%2BBhHvRqCCPVrKC3w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/7478C820-4C69-4305-9C06-B4D893D7D7F3%40icloud.com.
(defn run-unit-tests []
(repl/refresh)
(test/run-all-tests #"^(project-ns).*$"))
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/336c99ed-ed3d-4c10-8c0d-a089dbe3543f%40googlegroups.com.
Ok, so I looked into this briefly. I’ll need to try it to see how it will work since the test finding infrastructure in IntelliJ is fairly class-based. Hopefully I can make that translate nicely to namespaces. This also might affect test creation - “create test for this class” would normally create a test class, but I’m assuming in Clojure you’d want to create a test var inside an existing test namespace (creating it if required). I’m not sure how that mapping to vars should work - see below.
It seems that there are a couple of things here.
-test
and test
from namespace segments and then trying all combinations should be sufficient.<my-fn>-test
. Would you want mapping from other things to test vars, i.e. records or protocols? If anyone has ideas about how this mapping might work or be configured, let me know. One thing that this would help with is navigation - if the test searching is namespace based, when you navigate to test or navigate to source, you’ll end up with the caret at the namespace decl, i.e. at the top of the file.clojure.test
- if that needs refining later we can do that.I’m fine with just functions for now (would be a great start), but I don’t know what other people would want. Usually testing a record or protocol is more involved anyway.
> Finding test namespaces should be pretty straightforward as well - as a first cut I’ll just find all namespaces which depend on clojure.test
- if that needs refining later we can do that.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/etPan.592ce437.daa9379.18b6%40cursive-ide.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/CAHj4K5o5H%2B4VsC%3D3NyKxtpcB2Emaz1rRiNr2635uuybDa5D07w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/etPan.592ce437.daa9379.18b6%40cursive-ide.com.
For more options, visit https://groups.google.com/d/optout.
One other question - do you all like the UI with the icons painted in the gutter, or for a “Run all project tests” type thing would you prefer the standard IntelliJ test UI? The current one is more designed for interactive work, e.g. it doesn’t have an easy way to navigate to test failures in files that aren’t open in an editor. I could work something up for that if the current UI is preferable, though.
One potential issue with the built-in one is that it’s very much oriented to a process-based runner model, I’m not sure I can make it work in the REPL - I’ll have to investigate that.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/etPan.59360bfb.7fc1022f.18b6%40cursive-ide.com.
You can see what I mean here. Those screenshots are a little out of date, but you get the idea.
Pros/cons:
For reference, the standard test runner looks like this, i.e. it opens in its own tool window with a tree of results. For Clojure, I guess the top level of the tree would be Clojure namespaces, and the next level would be the vars.
Pros/cons:
clojure.test
- you can get multiple failures per test.To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/etPan.59361099.201c4112.18b6%40cursive-ide.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/7E6E882E-23F6-462A-A112-62C0F978E219%40icloud.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/etPan.59361099.201c4112.18b6%40cursive-ide.com.
For more options, visit https://groups.google.com/d/optout.
I spent some time looking into this yesterday. It looks like I can hopefully reuse the IntelliJ test UI even when running in a REPL, so that’s good. I’ll still have to work out which of the actions should create a run configuration - probably “Run all tests in project/module” should, but “Run test under caret” or “Run tests in file” should not - basically anything that can be easily run with a simple command is probably not worth it.
I think I can probably make it work so that it works as it does currently, but also allows the test UI to be shown - that seems like the best of both worlds. It seems like hiding the IntelliJ test UI by default is probably the best option, but allowing it to be opened to investigate if tests fail. That means that I can probably use the test UI even for the existing commands, and hopefully that will mean that I can capture the output per-test and show it there as well.
The first part of this (test navigation/creation) has been released today in 1.6.0-eap1. I’m very interested in feedback on how well it works. In subsequent 1.6.x releases I’m going to add the test runner/UI and REPL improvements.
I haven’t heard anyone saying that this is awful, so I’m going to release it as 1.6.0 today so that everyone can get a build with the locals clearing enabled (i.e. fixing up the 1.5.2 problem). There are a few minor issues with this still, they’ll be fixed in 1.6.1-*.
Cheers,
Colin