thomhurst / TUnit

A modern, fast and flexible .NET testing framework
MIT License
2.44k stars 38 forks source link

Test Discovery not working in JetBrains Rider macOS + Linux #576

Closed hquinn closed 2 weeks ago

hquinn commented 2 months ago

JetBrains Rider About

JetBrains Rider 2024.2.5
Build #RD-242.22855.90, built on September 19, 2024
Licensed to <redacted>
Subscription is active until <redacted>.
Runtime version: 21.0.3+13-b509.15 aarch64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.lwawt.macosx.LWCToolkit
macOS 14.6.1
.NET Core v8.0.4 ARM64 (Server GC)
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 2048M
Cores: 8
Metal Rendering is ON
Registry:
  ide.experimental.ui=true
  i18n.locale=
Non-Bundled Plugins:
  lermitage.intellij.extratci (2024.5.1)
  com.intellij.resharper.HeapAllocationsViewer (2024.2.0)
  com.thvardhan.gradianto (5.5)
  nsubstitutecomplete-rider (2024.2.0)
  com.intellij.ideolog (242.22855.37)
  com.markskelton.one-dark-theme (5.12.0)
  cognitivecomplexity-rider (2024.2.0)
  Key Promoter X (2024.2.0)
  Abc.MoqComplete.Rider (2024.1.1.1)
  com.intellij.resharper.StructuredLogging (2024.2.0.339)
  com.settler.rider.specflow (1.23.6)
  com.intellij.ml.llm (242.22855.75)
  com.github.dinbtechit.vscodetheme (1.10.11)
  com.github.copilot (1.5.23.6819)
  com.brandiico.jetbrains-nightfall-theme (2.0.2)

Project setup

I created a new solution with a class library (using .NET 8.0.401) using TUnit 0.1.783 (but have also tried on 0.1.752):

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="TUnit" Version="0.1.783" />
    </ItemGroup>

</Project>

Then I created the following class:

public class ExampleTests
{
    [Test]
    public async Task Sample()
    {
        bool actual = true;
        await Assert.That(actual).IsTrue();
    }
}

Running it via dotnet test appears to work:

  Determining projects to restore...
  All projects are up-to-date for restore.
  Example.UnitTests -> /Users/hquinn/Documents/Code/Example/tests/Example.UnitTests/bin/Debug/net8.0/Example.UnitTests.dll
  Run tests: '/Users/hquinn/Documents/Code/Example/tests/Example.UnitTests/bin/Debug/net8.0/Example.UnitTests.dll' [net8.0|arm64]

  ████████╗██╗   ██╗███╗   ██╗██╗████████╗
  ╚══██╔══╝██║   ██║████╗  ██║██║╚══██╔══╝
     ██║   ██║   ██║██╔██╗ ██║██║   ██║   
     ██║   ██║   ██║██║╚██╗██║██║   ██║   
     ██║   ╚██████╔╝██║ ╚████║██║   ██║   
     ╚═╝    ╚═════╝ ╚═╝  ╚═══╝╚═╝   ╚═╝   

     v0.1.783.0 | 64-bit | Darwin 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 | osx-arm64 | .NET 8.0.8 | Microsoft Testing Platform v1.4.0

  Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 78ms

  Test run summary: Passed! - /Users/hquinn/Documents/Code/Example/tests/Example.UnitTests/bin/Debug/net8.0/Example.UnitTests.dll (net8.0|arm64)
    total: 1
    failed: 0
    succeeded: 1
    skipped: 0
    duration: 112ms
  Tests succeeded: '/Users/hquinn/Documents/Code/Example/tests/Example.UnitTests/bin/Debug/net8.0/Example.UnitTests.dll' [net8.0|arm64]

But the tests are not being discovered. I've already checked "Enable Testing Platform", and I've downgraded Rider to 2024.2.4, but hasn't worked.

thomhurst commented 2 months ago

Sorry to hear @hquinn . Unfortunately this isn't something I can solve and sounds like a Rider issue for mac.

Rider is built to pick up tests using the new Microsoft testing platform protocol. I simply send messages with test statuses and it's up to the IDE after that point.

And just to check, you've built your project? As tests are discovered after a build.

If it's still not working after that I recommend creating an issue with Jetbrains

hquinn commented 2 months ago

Hi @thomhurst , I did build the project but didn't show anything in the Test Explorer.

I've logged an issue on YouTrack, so hopefully they will look into this issue.

Link: https://youtrack.jetbrains.com/issue/RIDER-117732/Enable-Testing-Platform-support-doesnt-display-any-unit-tests-from-TUnit.

devtekve commented 2 months ago

I am also experiencing this exact same issue on 2024.2.5

Mrxx99 commented 2 months ago

In this video it works when enabling testing platform:

https://youtu.be/dtdgm8lKJZU?t=3m35s

devtekve commented 2 months ago

In this video it works when enabling testing platform:

https://youtu.be/dtdgm8lKJZU?t=3m35s

We know, we tried, in macOS it is not working even with that enabled. Nick is on windows

DragoQCC commented 2 months ago

I ran into a similar issue in Rider when I made a new unit test project; since the template adds a reference to the Microsoft.NET.Test.Sdk package, it was also trying to generate an entry point for the tests, so TUnit wasn't showing up. It worked great once I removed that package reference and just had the TUnit reference.

thomhurst commented 2 months ago

Ah yes the Microsoft.NET.Test.Sdk package is problematic. It basically tells the project to run in the old VSTest mode. I need to update the docs to tell people to remove it!

thomhurst commented 2 months ago

However the project setup on the original post doesn't include that 😞

wshaddix commented 2 months ago

The same problem exists on Linux as well. I also filed an issue with Jetbrains for that. I did confirm it works as advertised on windows

devtekve commented 2 months ago

Ah yes the Microsoft.NET.Test.Sdk package is problematic. It basically tells the project to run in the old VSTest mode. I need to update the docs to tell people to remove it!

Oh! I thought this was something specific to me and I didn’t mention it, but yeah, I also had that issue. However, it is unrelated to the not showing up on rider for Mac and Linux

danielmackay commented 2 months ago

I have the same issue on Rider 2024.2.5, MacOS Sequoia and .NET 9 RC1

thomhurst commented 2 months ago

Anyone that has this issue i recommend upvoting this issue so that Rider prioritise the fix: https://youtrack.jetbrains.com/issue/RIDER-117732/Enable-Testing-Platform-support-doesnt-display-any-unit-tests-from-TUnit.

danielmackay commented 2 months ago

Anyone that has this issue i recommend upvoting this issue so that Rider prioritise the fix: https://youtrack.jetbrains.com/issue/RIDER-117732/Enable-Testing-Platform-support-doesnt-display-any-unit-tests-from-TUnit.

Done - I've asked my colleagues who use Rider + MacOS to do the same. 😄

thomhurst commented 1 month ago

Jetbrains have marked the issue as fixed.

Says it'll be available in the Next 2024.3 public build. 🤞

hquinn commented 1 month ago

Jetbrains have marked the issue as fixed.

Says it'll be available in the Next 2024.3 public build. 🤞

Have tested this feature in the '2024.3 EAP 4' version, but not much luck unfortunately. I've tagged two employees who have looked into the issue to hopefully shed this to light.

jacob7395 commented 1 month ago

Unfortunately they have closed the ticket. On rider 2024.2.6 on windows the discovery works when using TUnit 0.1.1082 but any version after that it disapplies for me.

I will add a comment to the ticket highlighting this.

thomhurst commented 1 month ago

The windows issue is new to me... I'll have to verify later

jacob7395 commented 1 month ago

After a bit more fiddling looks like it might be something to do with MSBuild, I was using 8.0.303 but the issue went away when using 9.0.100-rc.1.24452.12 🤷 not sure if people on linux/mac have tried that MSBuild version.

When I say fiddling what fixed it for me was building TUnit in Rider, since you have net 9 it forced Rider to switch MSBuild.

Might also explain why you don't get it in TUnit test project.

thomhurst commented 1 month ago

After a bit more fiddling looks like it might be something to do with MSBuild, I was using 8.0.303 but the issue went away when using 9.0.100-rc.1.24452.12 🤷 not sure if people on linux/mac have tried that MSBuild version.

When I say fiddling what fixed it for me was building TUnit in Rider, since you have net 9 it forced Rider to switch MSBuild.

Might also explain why you don't get it in TUnit test project.

Oh I know what this might be then. I recently upgraded the source generator libraries, and the .NET 8 compiler might not have the most up to date version, but .NET 9 does.

jacob7395 commented 1 month ago

Tried the same project I got working on my windows using the latest TUnit version with MSBuild 9.0, on my Fedora laptop. Even after switching to the MSBuild 9.0.1 still no luck, also didn't work at version 8.0.303.

To clarify the project is still at .NET 8 I just used MSBuild 9.0.1. Not sure if that would effect the source code generation :shrug: I do not know enough about how MSBuild works.

thomhurst commented 1 month ago

@jacob7395 0.1.1096 should be working again on Windows on .NET 8

jacob7395 commented 1 month ago

It seems to be working mostly now, I found an issue with using ClassConstructor's I'll write an example and open a separate issue.

philasmar commented 1 month ago

I have not been able to get Test Discovery to work using Rider on MacOS. Any updates on this?

thomhurst commented 1 month ago

It's in jetbrain's hands

jacob7395 commented 1 month ago

I am assuming this is also to do with jetbrains, but the test traceing is also not working for me. It discovers the test but if I double click on it don't direct me to the test file or test. I'll keep an eye on this issue, and update if it does or doesn't get resolved.

On Wed, 23 Oct 2024, 8:58 pm Tom Longhurst, @.***> wrote:

It's in jetbrain's hands

— Reply to this email directly, view it on GitHub https://github.com/thomhurst/TUnit/issues/576#issuecomment-2433318027, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFEEHKTPMCT6XQZQXOKB33Z475WHAVCNFSM6AAAAABOTK7A4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZTGMYTQMBSG4 . You are receiving this because you were mentioned.Message ID: @.***>

thomhurst commented 1 month ago

I am assuming this is also to do with jetbrains, but the test traceing is also not working for me. It discovers the test but if I double click on it don't direct me to the test file or test. I'll keep an eye on this issue, and update if it does or doesn't get resolved. On Wed, 23 Oct 2024, 8:58 pm Tom Longhurst, @.> wrote: It's in jetbrain's hands — Reply to this email directly, view it on GitHub <#576 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFEEHKTPMCT6XQZQXOKB33Z475WHAVCNFSM6AAAAABOTK7A4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZTGMYTQMBSG4 . You are receiving this because you were mentioned.Message ID: @.>

This isn't in the standard release yet but is supported in the latest EAP.

HOWEVER, it seems to only work for non-parameterised tests.

If you have a data driven test it doesn't work for some reason.

thomhurst commented 2 weeks ago

New version of Rider was pushed out today. Can anyone check if it's still an issue?

philasmar commented 2 weeks ago

Looks like it did! I can see my tests on 2024.3

thomhurst commented 2 weeks ago

Woohoo

jacob7395 commented 2 weeks ago

I'll check the update version although I have been on windows, another issue that may or may not be related. I can't double click navigate on failing tests, it a bit of a pain. I'll give it a try on the new version when I get a chance. If it's not related happy to open up a new issue

On Wed, 13 Nov 2024, 5:15 pm Tom Longhurst, @.***> wrote:

Woohoo

— Reply to this email directly, view it on GitHub https://github.com/thomhurst/TUnit/issues/576#issuecomment-2474253340, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFEEHLQBW62GMOGRJCZM7T2AOCMJAVCNFSM6AAAAABOTK7A4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZUGI2TGMZUGA . You are receiving this because you were mentioned.Message ID: @.***>

thomhurst commented 2 weeks ago

I'll check the update version although I have been on windows, another issue that may or may not be related. I can't double click navigate on failing tests, it a bit of a pain. I'll give it a try on the new version when I get a chance. If it's not related happy to open up a new issue On Wed, 13 Nov 2024, 5:15 pm Tom Longhurst, @.> wrote: Woohoo — Reply to this email directly, view it on GitHub <#576 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACFEEHLQBW62GMOGRJCZM7T2AOCMJAVCNFSM6AAAAABOTK7A4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZUGI2TGMZUGA . You are receiving this because you were mentioned.Message ID: @.>

Yeah this was another rider issue that should be resolved on the latest version

jacob7395 commented 2 weeks ago

After updating Rider yesterday still had issues with navigation, but I have not updated TUnit for a while I'll give it a try after updating this evening.

The other issue I noted was categories not appearing in the Test Explorer, I will give this a look tonight as well.

hquinn commented 2 weeks ago

Having tried this now in JetBrains Rider 2024.3, this is now working as I expect, although I do find this release to be quite buggy in general.

Having played around with TUnit using the command line up to now in a full project, it was quite pleasant to use. Thanks for the hard work. I'll close this issue now.

jacob7395 commented 2 weeks ago

Having tried this now in JetBrains Rider 2024.3, this is now working as I expect, although I do find this release to be quite buggy in general.

Having played around with TUnit using the command line up to now in a full project, it was quite pleasant to use. Thanks for the hard work. I'll close this issue now.

I might give the cli a try decrease my reliance on an IDE like a 'real dev' 🥹 second your thanks to @thomhurst, framework is still awesome in spite the IDE issues.

If the notification/navigation issue still occur I'll open an issue to keep track, sorry in advance

rubens-lopes commented 1 week ago

JetBrains Rider 2024.3 Build #RD-243.21565.191, built on November 12, 2024 Licensed to Rubens Armôa Lopes Subscription is active until October 2, 2025. Runtime version: 21.0.5+8-b631.16 aarch64 (JCEF 122.1.9) VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Toolkit: sun.lwawt.macosx.LWCToolkit macOS 15.1 .NET Core v8.0.4 ARM64 (Server GC) GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 4096M Cores: 10 Metal Rendering is ON Registry: ide.experimental.ui=true i18n.locale= Non-Bundled Plugins: com.github.rmehri01.onenord (0.1.4) CyclomaticComplexity (2024.3.0) IdeaVIM (2.16.0) org.OverEngineer.InlineProblems (0.5.3) fr.socolin.application-insights-debug-log-viewer (2024.2.0) com.arcticicestudio.nord.jetbrains (0.13.0) com.wakatime.intellij.plugin (15.0.3) org.jetbrains.plugins.github (243.21565.204-ultimate) com.github.copilot (1.5.29.7524)

Worked after Invalidate Caches... image

image

JakeSays commented 1 day ago

I don't think this issue is fully resolved. I started using TUnit with rider yesterday and everything was working fine until about an hour ago. Rider stared failing tests with Last runner error: Unable to write data to the transport connection: Broken pipe. and now it just refuses to recognize any tests in the solution. I'm on rider 2024.3

thomhurst commented 1 day ago

I don't think this issue is fully resolved. I started using TUnit with rider yesterday and everything was working fine until about an hour ago. Rider stared failing tests with Last runner error: Unable to write data to the transport connection: Broken pipe. and now it just refuses to recognize any tests in the solution. I'm on rider 2024.3

Id try invalidating caches and restarting. Worth raising with Jetbrains if it happens again