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
Skip attribute on [InlineData] is not respected in Visual Studio #266
Comments
Forgot to include version information in case it's helpful: dotnet --infoPS C:\Coding\broken-inlinedata-skip-repro> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.302
Commit: 9048955601
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.302\
Host (useful for support):
Version: 2.1.2
Commit: 811c3ce6c0
.NET Core SDKs installed:
2.0.3 [C:\Program Files\dotnet\sdk]
2.1.3 [C:\Program Files\dotnet\sdk]
2.1.100 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.200 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.300-rc1-008673 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.301 [C:\Program Files\dotnet\sdk]
2.1.302 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0-rc1-final [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0-rc1-final [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.0-rc1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download Visual Studio |
Does this only reproduce in Visual Studio? Can you reproduce it with any other runner? |
Sure I’ll try that later. Is that a feature that needs 2.4.0 to light up? Otherwise it’s a bit odd that the same version of VS would shoe different behaviours with different NuGet packages in use. |
I'm not sure why it's happening. I'm just looking for a way to narrow down where the issue might be. |
OK, so I'm trying this on my home laptop (above my was my work), and first time I opened and ran it was fine. The I turned discovery off and then it started to reproduce. Turned it back on and still reproduced it. Cleaned the solution and re-ran and it was behaving correctly again. Bizarre. It seems like it starts to happen once you rebuild the solution with the setting either way, but I'll need to play around more and restart VS in different combinations to see which scenario(s) the issue happens with. |
So, I did the following and it reproduces immediately and consistently:
|
I have the same issue; in Visual Studio the "Skip" property is ignored but in dotnet test it works fine. |
I'm having the same issue and after some testing found the following: |
@ReneGoos is correct. xUnit test adapter ignores Skip property on test-cases of a |
I did a little debugging on this, and I think I understand what's going on. Deserialization of When
This is happening because the property setter of This change happened in the following commit, which I think is only in 2.4.1 and not earlier versions xunit/xunit@dabc047 |
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782 \n\nCommit migrated from dotnet/extensions@cbe90b8
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782 \n\nCommit migrated from https://github.com/dotnet/extensions/commit/dotnet/extensions@dotnet/extensions@dotnet/extensions@cbe90b849230d9b24f3152a44fa8d714c332b1e4 \n\nCommit migrated from https://github.com/dotnet/extensions/commit/dotnet/extensions@dotnet/extensions@6bad1a5b982a6d30a66e7e22614018c35de2922a \n\nCommit migrated from https://github.com/dotnet/extensions/commit/dotnet/extensions@7c7b47dec563c95bd778d2bb56f58746410d00de \n\nCommit migrated from dotnet/extensions@25a9d91
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782 \n\nCommit migrated from dotnet/extensions@cbe90b8
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782 Commit migrated from dotnet/extensions@cbe90b8
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782 Commit migrated from dotnet/extensions@cbe90b8
We're currently experiencing a bug where conditional skips aren't working in VS. This is caused by https://github.com/xunit/xunit/issues/1782 Commit migrated from dotnet/extensions@cbe90b8
Workaround: Don't use Visual Studio Test Explorer. JetBrains Resharper Ultimate is your friend. |
@martincostello Why did you thumbs down the workaround. It actually works, and is something I didn't see explained. I found this issue because I temporarily disabled Resharper and used VS Test Explorer and ran into this problem, and it confused the heck out of me. |
It just came across as a bit of an "X is better than Y because it doesn't have this specific problem" sort of thing, like when people argue about iOS vs. Android, Windows vs. Linux etc. 😄 |
Well, I might believe that 😄, but I also believe that it's helpful to point out this may just be a screwy Microsoft bug, not a Brad Wilson/xunit issue. It might also be that Resharper is doing some hacky stuff to get this to work. |
@martincostello A new workaround: With the introduction of Assert.Skip and Assert.SkipWhen, you can encode skipping via adding a parameter to your InlineData. See: xunit/xunit#1913 (comment) CC @bradwilson https://github.com/martincostello/broken-inlinedata-skip-repro/blob/main/Tests.cs becomes: using Xunit;
namespace BrokenInlineDataSkip
{
public static class Tests
{
[Theory]
[InlineData(1, 1, 2, false)]
[InlineData(2, 2, 4, true)]
public static void Can_Add_Integers(int x, int y, int expected, bool skip) => { Assert.SkipWhen(skip, "Skipped"); Assert.Equal(expected, x + y); }
}
} |
@bradwilson Can this hopefully be included in xunit/xunit#2133? This bug has been present for 2 years now. |
@Happypig375 How does making the test self-hosting solve the problem that the IDE has bugs? Why does Resharper work but VS does not? |
@jzabroski Go read @rynowak's comment and come back to me. |
@Happypig375 I see. So technically, xunit moving to a tests-as-program model instead of tests-as-library model may actually exacerbate this problem if its just a data deserialization issue. |
@bradwilson Can this hopefully be included in xunit/xunit#2133? I hit this bug again today. |
One of my clients is seeing this exact bug - Theory with InlineData skip is not being respected:
This only happens in Visual Studio Test Runner. Has never happened in Shutting down VS, clearing the Visual Studio test cache for the solution doesn't seem to make a difference. For completeness, the following packages are installed in the test project:
|
This is really annoying and should be fixed not only in next major version, but also in version 2.x. |
Fixed in 2.4.2-pre.14 (currently on MyGet). The serialization of this class has changed in v3 with the move to traditional .NET Serialization, so the issue is not present in v3. |
When will this be available as on nuget.org as a non-prerelease? |
Soon, but no fixed date yet. |
@Issung wrote:
This should be fixed w/ xUnit.net 2.4.2. Make sure you've upgraded the core framework package(s). |
Works great for me. You need to use both Xunit and Xunit.runner to be successful, though. |
If the
Skip
property of an[InlineData]
attribute (or derived types ofDataAttribute
) is populated with a message that it should be skipped, either statically in code or at runtime, Visual Studio does not respect that value and runs the test when the Visual Studio Test Explorer is used.A repo containing a solution that demonstrates this issue can be found here: https://github.com/martincostello/broken-inlinedata-skip-repro
This appears to be a regression since xunit 2.3.1.
Running
dotnet test
using the CLI is not affected:xunit 2.3.1 Behaviour
xunit 2.4.0 Behaviour
The text was updated successfully, but these errors were encountered: