New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet test and VsTest swallows xUnit tests #2719
Comments
In microsoft/vstest#2123 is mentioned that the test adapter seems to capture the exception during discovery, because of that the Test2 and Test3 are not run and lost. I took a look at the SourceCode of the VsTestRunner. The Exception Handling while and An Exception should be logged. But on the diag logs of Theses are the only logs that the VsTestRunners seems to log to the testrunner from VS and dotnet test.
So, the Exception or whatever the reason is for not running Test2 and Test3 will be swallowed a level deeper. |
Any Ideas, About this? |
ReSharper relies also on the results of xunit and behaves not well because of that, https://youtrack.jetbrains.com/issue/RSRP-475867 |
I should not have transferred this, as it appears to be reproducible without VSTest, sooooo... transferring it back to the core project. |
@bradwilson Is this issue really fixed? We noticed a similar behavior, i.e., swallowed tests caused by an exception outside of the actual test code. A minimal example that reproduces the issue: public class CustomFactAttribute : FactAttribute
{
public override string? Skip => throw new InvalidOperationException("I would like to see this issue...");
}
public class UnitTest1
{
[CustomFact]
public void Test1()
{
Assert.Fail("This test should fail.");
}
} If run via ReSharper, we can see the exception and the inconclusive test: If instead run via $ dotnet test
Determining projects to restore...
All projects are up-to-date for restore.
xunitbug -> /Users/MAO1LB/Downloads/xunitbug/bin/Debug/net8.0/xunitbug.dll
Test run for /Users/MAO1LB/Downloads/xunitbug/bin/Debug/net8.0/xunitbug.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.8.0 (arm64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test is available in /Users/MAO1LB/Downloads/xunitbug/bin/Debug/net8.0/xunitbug.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. |
This must be a different issue, I'll see what I can track down. |
Fixed in v2 I have other work to do with v3 related to this that will probably take a bit longer, as it's failing in a different way, so I'm going to leave the bug open for now until I can resolved the v3 issue(s). @aomader Your example now: |
Fixed in v3 |
@bradwilson Awesome, thank you very much! Probably one of the speediest replies PLUS fix I have ever seen on GitHib. Kudos! 🥇 |
copied from xunit/visualstudio.xunit#164 and xunit/visualstudio.xunit#165.
xunit swallows silently xunit tests (maybe also test from other test frameworks) when there is a problem on the test discovery. I filed the same thing in the dotnet cli repo: https://github.com/dotnet/cli/issues/12187
Steps to reproduce
Checkout the repository https://github.com/DerAlbertCom/MisbehavingUnittestRunners run dotnet test. More details why the problem occurs is also there.
Expected behavior
At least the exception within the test discovery shows up. It would be better if it is possible to give more detail on exact type or test method.
Actual behavior of dotnet test
In the sample repository are 6 Unit Test, 2 of them get swallowed without any hint because of an exception within the test discovery on one test.
Actual behavior of Visual Studio
Test withing Visual Studio 2019 16.2
.
In the sample repository are 6 Unit Test, 2 of are not run without any hint because of an exception within the test discovery on one test.
Environment data
The text was updated successfully, but these errors were encountered: