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
Bug: Empty params inline data #2456
Comments
What are you expecting to happen? What happens if you provide an empty array as arguments to the InlineData attribute as one normally would? |
I'm expecting the test successfully passed both targeting net461 and net5.0. |
Right, what I was nudging at is that I suspect that it will work fine if you actually pass (an empty array of) arguments in the InlineData like one normally would Whether it's xUnit or .NET that's issuing the exception, I think its useful that it rejects that case. But even then - InlineData with no arguments does not really make a lot of sense. |
Plus: when test method has parameter with |
I agree that it is inconsistent behavior, and its good that you have provided a repro. As for whether its possible or important to fix, that's what I'm more pushing back on as a courtesy to the maintainers - I'd like to see their precious time they donate to us be invested in V3 timeframe stuff for .NET Core only. I'm not sure what the root cause is - whether its down to Reflection impl changes in .NET, the C# compiler or something else. Its possible that something can be done in InlineDataAttribute or in the Theory impl, but I personally would see this as a low priority issue as:
|
I really appreciate works that maintainers has devoted to this project. However, if I'm care taker of the project, I would be curious to find out the reason for the inconsistent behavior, at least. |
Hm, I missed the point that there does not seem to be a syntax that works to pass an empty array - I was more quibbling about whether So yes, no harm to log it on that basis (but the most helpful thing of all would be a PR - its not only on the mainainer ;P) |
The problem appears to be with theory data pre-enumeration. I'm not sure whether it's in the core framework or the VSTest adapter. As a workaround, you can follow the documentation instructions for adding a configuration file and set {
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"preEnumerateTheories": false
} |
It appears there is a downside of setting I end up with putting |
Rather than disabling the test case, the workaround I'd suggest is to use |
No, that won't help. The bug isn't in data discovery, it's in serialization.
Using xunit/src/xunit.core/MemberDataAttributeBase.cs Lines 30 to 35 in b88fee5
|
If pre-enumeration is disabled, I would rather prefer to write traditional
IMO the biggest advantage of
|
I agree in general, but it can work given the right conditions |
Similar story with me: I came back to a project in a newly-installed copy of VS2022 only to find several, params-array InlineData tests had broken. I'm not sure when they broke, but I don't have much time to devote to this so, in case it helps anyone, I worked around it using |
Here's what I see for
So serializing the empty xunit/src/xunit.execution/Sdk/Frameworks/XunitTestFrameworkDiscoverer.cs Lines 166 to 167 in 93616f7
It seems like the bug may be inconsistency in populating |
This bug was likely introduced when support for parameter defaults was added. When the code was written, "no parameters" meant "this is a |
(Another way to say this is: originally, |
I'm wondering if dropping
|
That's because AcceptanceTestV2 on the |
The following test will success when targeting net461, whereas failed targeting net5.0 with error message
System.InvalidOperationException : The test method expected 1 parameter value, but 0 parameter values were provided.
:Repo: https://github.com/weifenluo/XUnitEmptyParamsBug
The text was updated successfully, but these errors were encountered: