Skip to content
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

In Rider or ReSharper theory where all test cases were skipped is displayed as failed because SkipException increases TestsFailed counter #33

Open
ivanskorikov opened this issue Sep 16, 2024 · 9 comments

Comments

@ivanskorikov
Copy link

When using Rider or R# test runner, a theory with skipped test cases is displayed as containing failing tests.

public class Test
{
	[SkippableTheory]
	[MemberData(nameof(WorkingData))]
	public void WorkingTest(IEnumerable<string> a)
	{
		throw new SkipException();
	}

	[SkippableTheory]
	[MemberData(nameof(FailingData))]
	public void FailingTest(IEnumerable<string> a)
	{
		throw new SkipException();
	}

	public static TheoryData<IEnumerable<string>> WorkingData()
	{
		return new() { Array.Empty<string>() };
	}

	public static TheoryData<IEnumerable<string>> FailingData()
	{
		return new() { Enumerable.Empty<string>() };
	}
}

image

The TestCaseFinished event gets fired two times: once for FailingTest and once for WorkingTest.

For FailingTest, the display property is set FailingTest, which causes it to match to the parent node. And non-zero TestsFailed is why we interpret it as failed.
image

For WorkingTest, display is WorkingTest(a: []). And although TestsFailed is also non-zero, it's the second time a result gets reported for that element (the first being the dedicated OnTestSkippedEvent), so we discard it entirely.
image

Please consider handling SkipException in a way that would not count towards TestsFailed counter.

Originally reported here: RIDER-99523 Skipped theory tests are marked as failed when an IEnumerable is used as a value (Xunit.SkippableFact)

@AArnott
Copy link
Owner

AArnott commented Sep 20, 2024

Thanks for this thorough report. I'm surprised to learn that these tests are reported as failed. I can look into that. I'm not sure when I'll get to it. I'd welcome a PR.

@AArnott AArnott self-assigned this Oct 1, 2024
@AArnott
Copy link
Owner

AArnott commented Oct 1, 2024

This is how SkippableFact avoids this problem:

result.Failed -= messageBusInterceptor.SkippedCount;
result.Skipped += messageBusInterceptor.SkippedCount;

SkippableTheory has exactly the same code:

result.Failed -= messageBusInterceptor.SkippedCount;
result.Skipped += messageBusInterceptor.SkippedCount;

But in the latter case, this code is not called. I don't yet know why. But at least that partly explains why they are reported as failures in Rider.

@AArnott
Copy link
Owner

AArnott commented Oct 1, 2024

Ok, for reasons unknown, although SkippableTheoryTestCase isn't called, the SkippableFactTestCase is called. So either way, the code to decrement Failed and increment Skipped executes.
So I don't know what might be going wrong in R# or Rider. I don't have a license to either so I can't investigate further.

If Jetbrains were to comp me a license, I'd be happy to investigate further.

@AArnott AArnott removed their assignment Oct 1, 2024
@0xced
Copy link
Contributor

0xced commented Nov 28, 2024

@ivanskorikov Is this still an issue with Rider 2024.3 (Build #RD-243.21565.191)? I could not reproduce your issue.

Xunit SkippableFact issue 33

Also @AArnott, JetBrains announced that WebStorm and Rider Are Now Free for Non-Commercial Use last month.

@dArignac
Copy link

dArignac commented Dec 3, 2024

@0xced I have the same issue and I am still seeing this in Rider 2024.3 (Build #RD-243.21565.191).

0xced added a commit to 0xced/Xunit.SkippableFact that referenced this issue Dec 3, 2024
@0xced
Copy link
Contributor

0xced commented Dec 3, 2024

What version of xunit and xunit.runner.visualstudio are you using?

Also, what happens if you try with the Issue33 project from this branch on my fork?

@dArignac
Copy link

dArignac commented Dec 4, 2024

It is xunit 2.9.2 & xunit.runner.visualstudio 2.8.2 for me.
I am not sure how to build and use the code in your branch, tbh.

0xced added a commit to 0xced/Xunit.SkippableFact that referenced this issue Dec 4, 2024
@0xced
Copy link
Contributor

0xced commented Dec 4, 2024

I am not sure how to build and use the code in your branch, tbh.

git clone https://github.com/0xced/Xunit.SkippableFact/
cd Xunit.SkippableFact
git checkout issue33

Then open Xunit.SkippableFact.sln in Rider and run the Issue33 test and post the same screenshot as I posted above.

@dArignac
Copy link

dArignac commented Dec 4, 2024

Thanks, I ran it. There it is alright.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants