Hopefully I am reporting this in the correct place, sorry if not!
Running in either VS2017 or using dotnet test, the runner hangs indefinitely if the JsonConvert.DefaultSettings have been set as below:
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new SnakeCaseNamingStrategy()
}
};
I have tested this using MSTest, Nunit and Xunit and the same issue seems to happen across the board, which leads me to believe its the vstest runner itself.
XUnitTestProject1.zip
Above is a sample project with 2 tests. One which hangs and one which doesn't.
For the tests to finish running
Tests never finish running. I have to go and end the dotnet process manually.
Windows 10, .net core 2.0
@ejcoyle88 , We use JsonConvert.SerializeObject to serialize the message we need to send back to vstest runner. Since you are modifying the default Json Serializer, vstest.console does not understand the message it receives from testhost process. Meanwhile testhost is waiting to receive an appropriate shutdown message from vstest.console, which it never receives. This is causing the system to be in hung state.
Can you please change your test code to not modify Default settings of JsonConvert, rather create your own custom Json Serializer, & use it serialize data? You can take reference from here.
Hi @mayankbansal018,
We've already gone ahead and reworked our projects to use the serializer this way. 馃槃
I reported the issue because many guides seem to suggest setting your JsonConvert settings using the DefaultSettings property, and so this may be an issue other people also see.
If this isn't something that can be fixed within the test runner, it would be much better for debugging if the runner could report an error when the JsonConvert.DefaultSettings are in a form that would cause it to hang.
@ejcoyle88 , thanks for bringing this issue. Investigating this helped us realized how our serialization can get impacted. We plan to discuss this further internally.
The code is open source anyways, if you get a chance, please feel free to contribute.. 馃槂
Most helpful comment
@ejcoyle88 , thanks for bringing this issue. Investigating this helped us realized how our serialization can get impacted. We plan to discuss this further internally.
The code is open source anyways, if you get a chance, please feel free to contribute.. 馃槂