ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Review test running associated commands

Open vinistock opened this issue 2 years ago • 2 comments

We added specific commands to be able to run tests, but after double-checking the default keybindings I realized that this is already possible out of the box.

There are several commands to run or debug tests, like

  • testing.debugAll
  • testing.runAll
  • testing.debugAtCursor
  • testing.runCurrentFile
  • testing.runAtCursor
  • testing.reRunLastRun
  • testing.reRunFailTests

I don't think we needed the implementation from Shopify/vscode-ruby-lsp#696 and I don't believe we need the implementation from Shopify/vscode-ruby-lsp#708 and Shopify/vscode-ruby-lsp#717.

Let's confirm that this is the case and

  • Revert the changes in Shopify/vscode-ruby-lsp#696
  • Document what the default keybindings for interacting with the test explorer are somewhere. People can easily change their keybindings if they want to

vinistock avatar Sep 08 '23 13:09 vinistock

I verified these work when called from the command menu:

  • testing.runAtCursor
  • testing.debugAtCursor
  • testing.runCurrentFile
  • testing.reRunFailTests (odd that it's fail and not failed)
  • testing.reRunLastRun

testing.runAll also works, but for our extension I don't think there would be any difference than testing.runCurrentFile, since the explorer only covers the currently active file.

Something else I noticed - many of these already have keybindings. They use Command-; like a modifier, e.g. to re-run the last test it's Command-; followed by l.

The one that doesn't work currently is testing.debugAll but that doesn't seem very useful.

andyw8 avatar Sep 19 '23 18:09 andyw8

This issue is being marked as stale because there was no activity in the last 2 months

github-actions[bot] avatar Nov 19 '23 12:11 github-actions[bot]

I find the rubyLsp.runTestInTerminal command useful because:

  • I can run all tests in the current file by triggering it on my top level describe/context block. This is much faster than running via test explorer, which seems to start a new process for each individual test.
  • I can make edits while the tests are running, e.g. if I see an error start to occur and I know what fix I want to implement before the run has finished
  • I find the output more useful - when I run via test explorer, I don't see errors in the Test Results panel unless I specifically click on a failed test in there (extra clicks). Or if I have the "peek view" enabled, but I find that very visually confusing because now my error output is inserted into the document I'm trying to edit. I don't know if there's a way to fix this, and I haven't investigate how it works on other language platforms, so maybe it can be improved.

I'd like to have something equivalent to rubyLsp.runTestInTerminal that:

  • Runs the entire test file (i.e. no :XX line number suffix) -- equivalent to testing.runCurrentFile
  • Re-runs the last test run (either entire file or specific line) -- equivalent to testing.reRunLastRun

jonleighton avatar Nov 18 '24 05:11 jonleighton

Thanks for the suggestions, those are great ideas. It's not well described in the issue, but the idea was just to avoid the duplication for the test explorer commands, which already exist and yet we created duplicates for.

For run in terminal, indeed having those new commands would be great.

vinistock avatar Nov 18 '24 14:11 vinistock

Because run in terminal is now associated with new Test Explorer implementation, all concerns with this issue will be addressed and available when it's rolled out.

alexcrocha avatar May 12 '25 18:05 alexcrocha