MSTest v2.2.4 not working for some data tests: System.ArgumentException: Object of type 'System.Int32' cannot be converted to type 'System.UInt32
See original GitHub issueDescription
After upgrading to MSTest 2.2.4 I’m getting System.ArgumentException for data tests with some data types
Steps to reproduce
- MSTest 2.2.4
- Create this test:
[TestMethod]
[DataRow(0U)]
[DataRow(1U)]
[DataRow(2U)]
public async Task TestWithUint(uint index)
{
//ellided
}
Expected behavior
- Test to run without exceptions as prior to v2.2.4
Actual behavior
- Getting the exception:
System.ArgumentException: Object of type 'System.Int32' cannot be converted to type 'System.UInt32'.
Stack Trace:
RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
MethodBase.Invoke(Object obj, Object[] parameters)
ThreadOperations.ExecuteWithAbortSafety(Action action)
Environment
Windows 21H1 build 19043.1023 VS 16.9.6
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
c# - MSTest - DataTestMethod throws exception System. ...
I have a simple parameterized unit test in a .NET Core 3.1 test project (using MSTest) which runs successfully. It looks something like...
Read more >Type issues with data driven tests in MSTest | Damir's Corner
ArgumentException : Object of type 'System.Decimal' cannot be converted to type 'System.Double'. The error was limited to tests with non-integer ...
Read more >A brand new website interface for an even better experience!
MSTest v2.2.4 not working for some data tests: System.ArgumentException: Object of type 'System.Int32' cannot be converted to type 'System.UInt32.
Read more >XUnit: Using TheoryData with Theory - Code and languages —
Multiple in the XUnit 2.4.2 assertion library. ... System.ArgumentException : Object of type 'System.Int32' cannot be converted to type ...
Read more >C# 11 and . NET 7 - Modern Cross-Platform Development ...
Chapter 3: Controlling Flow, Converting Types, and Handling Exceptions ... Building websites using a content management system • 533.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Haplois I will share a complete project when I have more time, but in general, consider a test case like this:
with
GetData
similar to this:If I run such test cases in parallel (method level parallelism) then I see all kinds of exception suggesting that the the test framework attempts to pull the enumerable on different threads. I have plenty of data sources structured like this:
These obviously can’t be pulled in parallel either.
@paul-michalik thanks for reporting this. We’ll we working on fixing this. You can track it here #906.