testfx
testfx copied to clipboard
StackOverflowException running tests with DynamicData where the target class uses JToken (and dynamic).
Description
A StackOverflowException occurs running a DataTestMethod test using DynamicData when the target POCO class includes a JToken as a Dictionary TValue type. Note, the same thing occurs if I change JToken to dynamic.
Steps to reproduce
See attached sample solution and run tests.
Expected behavior
The test receives the test case deserialized as expected without a StackOverflowException occurring.
Actual behavior
The Newtonsoft.JSON deserialization works as expected -- the object's dictionary contains one item whose value is JArray -- however, there is XML serialization happening in the DynamicDataAttribute's code that is causing a StackOverflowException.
Environment
- macOS Big Sur
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NFluent" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MSTestSerializationIssue\MSTestSerializationIssue.csproj" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Example.json" />
<EmbeddedResource Include="Resources\Example.json" />
</ItemGroup>
</Project>
FWIW, I am also seeing this.
I am also having this issue. I already spent many hours investigating this issue, without any solution. Any Test Method that use DynamicData with more complex data type like objects and JObjects are failing. But, if I use simple parameters like strings or numbers it works.
Encountered this as well. For now i'll probably make a workaround by passing indices of array of test data objects to the test method but i'd like to see a proper solution...
Having same issue. Version 2.2.3 of MSTest.TestAdapter works as expected so for now had to downgrade as a workaround.
Please see this for solution.
I am currently investigating this issue and it's not linked to the test ID generation (my initial thought). It seems to be linked to some interaction between Test Platform and MSTest because MSTest 2.2.3
does work as long as I stay on 16.X
of TP but using MSTest 2.2.4+
with TP 16.X
also fails.
I will dig deeper to understand what's going-on.
Hey folks! It looks like it was fixed by some changes we did in MSTest in the new release we are working on. I have added a test case (and did some manual test) and I cannot repro on main of MSTest (I can repro using released version up to 2.2.10).