Cursive supports integration with testing frameworks with immediate feedback in the editor. This allows a tight feedback loop when developing tests using the REPL.
Currently the test integration only supports the default
clojure.test. You can run the tests by starting a REPL and then using Tools→REPL→Run tests in current NS in REPL - you can assign a shortcut to this action, of course. This will load the namespace containing the tests and any of its dependent namespaces (see here) in the REPL and then execute the tests from that namespace. You will see a summary popup at the cursor, and you’ll see the tests in the editor marked with the results. You will also see a summary of the test results printed to the REPL.
Each assertion will get a gutter icon showing the status of the test, and test errors or failures will also be shown in the error stripe margin at the right of the editor. You can get the details for a test failure from the tooltip on either of these two sites.
If the test is a comparison failure between two strings, the tooltip will contain a link to open a diff view of the differences between the two strings. You can also click directly on the gutter icon in this case to see the diff.
If you’re just working on a focused part of your test code, you can use Tools→REPL→Run test under caret in REPL, which as the name implies will just run a single test instead of the whole namespace.
You can use Tools→REPL→Clear all test markers to clear all the test annotations from your editor. You can also use Tools→REPL→Re-run last test action in REPL to re-execute the last test action you executed. You don’t have to be in the same namespace for this to work, so for a TDD-style workflow you can write your tests then re-run them while editing the code under test. Obviously you won’t see the test annotations with this unless you have the test code open in another editor pane.
Coming Soon: Support for Expectations and Midje.
Coming Soon: We’ll be investigating the possibility of using diffs for data structures as well as strings.