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

Use ancestors to determine test framework in code lens

Open vinistock opened this issue 1 year ago • 3 comments

Depends on #1333

We currently try to determine the test framework based on dependencies. This is an okay approach, but once we have ancestors available we can be a lot more accurate.

We can check if a test inherits from Minitest::Test or Test::Unit::TestCase and then decide based on that - ideally with a fallback if we can't determine the framework for whatever reason.

vinistock avatar Jan 29 '24 18:01 vinistock

That would be great.

andyw8 avatar Jan 29 '24 19:01 andyw8

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

github-actions[bot] avatar Mar 30 '24 12:03 github-actions[bot]

As a note, when we implement this, we should look for extend ActiveSupport::Testing::Declarative instead of < ActiveSupport::TestCase.

That would let us support users who want to support the declarative syntax of AS::TC, who don't wish to use the whole thing.

amomchilov avatar Jun 17 '24 16:06 amomchilov

+1 This would be a great feature!

justinallenmarsh avatar Oct 30 '24 18:10 justinallenmarsh

+1 - I use rspec-mocks in a project, but use Minitest as the test runner and Ruby LSP is detecting the test framework as rspec because it's only checking for the string rspec in any of the dependencies. The code lenses are not showing up in the Minitest tests, or in the Test Explorer.

Can an option be added to explicitly override the test framework?

ricksuggs avatar Jan 08 '25 22:01 ricksuggs

Can an option be added to explicitly override the test framework?

I would rather just implement the correct solution straight away. I'd avoid adding more configuration for something we can properly detect automatically.

Also, there are other corner cases that wouldn't be covered, like someone who reported using both RSpec and Minitest in the same application.

vinistock avatar Jan 09 '25 15:01 vinistock

While I understand not wanting to add an additional configuration option, doing so solves many of the use-cases quickly and the auto mode can be incrementally improved until it won't be as necessary.

nhumble-sa avatar Jan 30 '25 16:01 nhumble-sa

Complete in the new implementation of the explorer that's currently rolling out to users.

vinistock avatar Jun 04 '25 17:06 vinistock