Fork me on GitHub
#cursive
<
2020-04-15
>
elahti09:04:07

I don't know if this is a Cursive issue or not but on the latest IntelliJ IDEA the small menu on the bottom of the IDE from which you can choose to use parinfer or paredit has disappeared. Any idea if it can be restored there somehow?

jtth19:04:52

In the REPL, if I have softwrap on on input, I can’t move the cursor using keyboard arrow keys beyond the current line’s beginning. Is this intentional?

jaime20:04:29

Hi. I'm interested to know how you are doing your test workflow. Like tools you're using, how you run/re-run tests, (and how you reload chnages). Are you using terminal or running in repl integrated with editor? Thanks for sharing

jaime07:04:53

My workflow right now is using the cursive test integration (https://cursive-ide.com/userguide/testing.html). Basically I created shortcut to run/rerun the tests. To reload the changes from multiple namespace, I use the cursive "sync files in repl". If that does not seem to work I reload namespace using (clojure.tools.namespace.repl/refresh) with mount to reset the state. I created a helper method in dev.clj called reset, and created a repl command to assign a keyboard shortcut.

#_dev.clj
(defn reset []
  (stop)
  (toolnamespace/refresh :after 'dev/go))
Things that I don't like about the workflow: 1. If have to go to the test file in order to see the test results information 2. I have inconsistent way of reloading the state (sometimes "sync files" or "reset" the state). I wonder if above can be solved by (will try them soon): 1. Just run the test in terminal 2. Just run reset everytime before I run test (I wonder if it works). In cursive/intellij, you can configure that I believe I've read somewhere also about using rich comment where you write production and test code in comment (in the same namespace), then once you're done writing them, you cut and paste test code to the test namespace. I'm curious to know how that works for you guys.

onetom11:04:15

I'm just pressing Cmd-R from either the file of the implementation or the test namespace and that syncs the changed files 1st before rerunning the latest tests. I don't think I had to do any customization for this; that's how it works out of the box. To run a test for the 1st time, I haven't bothered to create any shortcuts. I simply press Cmd-Shift-A to evoke the Actions popup, then type "run te". That will bring the 2 actions for running either individual test or all tests to the top of the popup.

onetom11:04:12

u must be in a test namespace and a repl must be in focus for the project u r editing, otherwise u wont see these menu items

onetom11:04:17

to see the test failures, i often just press F2 to show the 1st failure around the caret. unfortunately it moves the cursor away from the point of editing and the popup explaining the error is not very readable. sometimes that popup have a blue link to show diffs between the actual and expected results, but currently there is no keyboard shortcut which would activate the dialog that link leads to.

onetom11:04:38

im also using expectations.clojure.test so i can write (expect <expected> <actual>) instead of (is (= <expected> <actual>)). in this case, the error failure contains (=? ... which cursive doesn't understand and doesn't even show the Show diff... link.

onetom11:04:49

example error msg:

Expected: (=? #{:with-update-and-merchantx} (-> txn-descr-merchant-by-human-q (d/q db [:txn.descr/str "txn-descr"]) (idents db)))
Actual: (not (=? #{:with-update-and-merchantx} #{:with-update-and-merchant}))

onetom11:04:57

if im dealing with bigger data structures in my tests, i just fire up kaocha in the built-in terminal, OR kaocha actually has some REPL integration, so u can just run specific tests or test specific namespaces with a function call. such a function call i just type up in the cursive repl window's input area directly, then i use my custom F12 shortcut to repeatedly execute the last expression in the REPL but first sync the current file im editing.

onetom11:04:02

for that you have to create a new REPL command with the Add New REPL Command action, like on this screenshot

onetom11:04:08

and then assign it to a keyboard shortcut (like F12) within the keymap. you will find this REPL action there by the name u assigned to it (like Re-execute last command in this example)

jaime17:04:31

For your shortcut cmd+r , what is the name of the command in the keymap? Pressing cmd+r on mine restarts the repl.

jaime17:04:44

"to see the test failures, i often just press F2 to show the 1st failure around the caret." Just to confirm, this will only work if your editor is focused in the test file where the error is right? Meaning if I moved to a different file and pressing f2 , then it won't go to the test file where the error is? (that is the case in my machine)

jaime18:04:51

Btw, there is a command "Error Description" where it will also show the tooltip of test error. Your cursor needs to be in the highlighted error though.