TUnit icon indicating copy to clipboard operation
TUnit copied to clipboard

Rider only discovers tests after restarting Rider

Open uldahlalex opened this issue 9 months ago • 3 comments

Tested IDEs: Rider 2025.1.1 Rider 2024.3.7

The green "run" button does not appear after writing a new test. However, when restarting the IDE it does appear.

Relevant settings:

Image

Example of the green button appearing after restart:

Image

I wasn't sure if I should report this as a TUnit issue or Rider issue, so I'm reporting it both places.

uldahlalex avatar May 07 '25 10:05 uldahlalex

It'll be a rider issue. The green play may/should appear after building after writing a new test. But yeah rider would need to make some bespoke functionality to detect tests without a build.

thomhurst avatar May 07 '25 11:05 thomhurst

I also use Rider, generally I find it works if you build first, but yeah, it can't discover the new test until you build.

andrewimcclement avatar May 14 '25 09:05 andrewimcclement

My experience is also that with 2025.1.2 tests get discovered after build and you get the green play button and can jump to the tests from test explorer. Sometimes you need to close the file though.

However, there is one exception. If you have added the ClassDataSource attribute to the test class, then the tests in the class will still appear in the explorer and you can run them from there, but navigation to the test does not work, the green button do not appear and also keyboard shortcuts to run the tests do not work:

// Has issues with Rider test tooling
[ClassDataSource<Fixture>(Shared = SharedType.PerTestSession)]
public class ExampleTest
{
    private readonly Fixture _fixture;

    public ExampleTest(Fixture fixture)
    {
        _fixture = fixture;
    }

    [Test]
    public async Task Test()
    {
        var actual = _fixture.Value;
        await Assert.That(actual).IsLessThan(2);
    }
}

To work around I've been setting the fixture to a property instead, so something like:

// Tests get discovered and can be navigated to
public class Example2Test
{
    [ClassDataSource<Fixture>(Shared = SharedType.PerTestSession)]
    public required Fixture Fixture { get; init; }

    [Test]
    public async Task Test()
    {
        var actual = Fixture.Value;
        await Assert.That(actual).IsLessThan(2);
    }
}

Visual Studio does not seem to suffer from same problem, so assuming this is also just a Rider specific issue, but thought I'd share this in case anyone else is running into this inconvenience.

Jaah avatar May 14 '25 12:05 Jaah

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jun 14 '25 00:06 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jun 19 '25 00:06 github-actions[bot]