Skip to content
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

Tests never finish when JsonConvert DefaultSettings changed #1360

Closed
ejcoyle88 opened this issue Jan 4, 2018 · 3 comments · Fixed by #4581
Closed

Tests never finish when JsonConvert DefaultSettings changed #1360

ejcoyle88 opened this issue Jan 4, 2018 · 3 comments · Fixed by #4581
Assignees
Labels

Comments

@ejcoyle88
Copy link

ejcoyle88 commented Jan 4, 2018

Description

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.

Steps to reproduce

XUnitTestProject1.zip
Above is a sample project with 2 tests. One which hangs and one which doesn't.

Expected behavior

For the tests to finish running

Actual behavior

Tests never finish running. I have to go and end the dotnet process manually.

Diagnostic logs

logs.zip

Environment

Windows 10, .net core 2.0

AB#1866683

@cltshivash cltshivash added the bug label Jan 9, 2018
@abhishkk abhishkk self-assigned this Jan 16, 2018
@abhishkk abhishkk assigned mayankbansal018 and unassigned abhishkk Feb 12, 2018
@mayankbansal018
Copy link
Contributor

@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.

@ejcoyle88
Copy link
Author

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.

@mayankbansal018
Copy link
Contributor

mayankbansal018 commented Feb 13, 2018

@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.. 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants