-
Notifications
You must be signed in to change notification settings - Fork 262
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
MSTest v2.2.4 not working for some data tests: System.ArgumentException: Object of type 'System.Int32' cannot be converted to type 'System.UInt32 #871
Comments
Similar issue but different exception when my unit test accepts custom class:
NuGet packages when it works: <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" /> and when it doesn't: <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.4" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.4" /> Code: [DynamicData(nameof(GetData), DynamicDataSourceType.Method)]
[DataTestMethod]
public void MyTest(Account account)
{
}
private static IEnumerable<object[]> GetData()
{
yield return new object[]
{
new Account()
};
} |
Please use latest packages : |
@Sanan07 do you know when a stable version with the fix is planned to be release? |
@Haplois can advice on it. |
15th of this month, @abatishchev. |
* - *FIXED:* Update to Dacpac change scripts to identify new header delimiter - *FIXED:* Issue creating scripts between incompatable SQL Server versions. Will now output a warning and continue to create the scripts with the flag `AllowIncompatiblePlatform=true` - *ADDED:* New command `sbm create` to create a new SBM file from a list of scripts - *UPDATED:* Can now use Windows auth for DACPAC creation - *UPDATED:* updated Nuget packages - Cleaning up compiler warnings * Updating Dac tooling version * Updating MSTest.TestAdaper and MSTest.TestFramework as per microsoft/testfx#871
@Sanan07 and others: v2.2.5-preview fixes the data collection issues with DynamicData but it removes the ability to run tests cases in parallel. I went to v2.2.2 this is the last version which supports DynamicData properly AND executes tests in parallel (Scope = MethodLevel) |
@paul-michalik, we didn't discontinue support for running tests in parallel. You should still be able to run DynamicData tests in parallel in our latest preview. Do you have a repro for your issue? |
@Haplois Yes! Given a test suite with data driven test cases with a IEnumerable<object[]> data source, if I let the test cases run in parallel with method level parallelism then InvalidOperations exceptions are thrown because of parallel access to the Enumerables. It looks as if the data source Enumerables were Move-d from different threads for the same test case. I realized that I do not know whether or not a single threaded access for pulling the data for each test case is actually guaranteed but it looks like, with v2.2.5, this assumption doesn't apply. |
@Haplois I will share a complete project when I have more time, but in general, consider a test case like this: [
DataTestMethod,
DynamicData(dynamicDataSourceName: nameof(GetData), DynamicDataSourceType.Method)
]
public async Task Create_Tasks_Requests_From_Invalid_Tasks_Definitions_Should_Return_BadRequest_Errors(Events.APIGatewayProxyRequest request, Requests.CreateTaskCommand.Arguments arguments)
{
// test code
} with public static IEnumerable<object[]> GetData() =>
new [] {
new [] object {
// initialize pair of objects
},
new [] object {
// initialize pair of objects
},
} 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: public static IEnumerable<object[]> GetData()
{
yield new InputData {
// ...
};
yield new InputData {
// ...
};
// etc.
} 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. |
Description
After upgrading to MSTest 2.2.4 I'm getting System.ArgumentException for data tests with some data types
Steps to reproduce
Expected behavior
Actual behavior
Environment
Windows 21H1 build 19043.1023
VS 16.9.6
The text was updated successfully, but these errors were encountered: