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

[ClientRuntime] Fixing spurious test failures in JsonSerializationTests #4060

Merged
merged 1 commit into from
Feb 10, 2018

Conversation

brjohnstmsft
Copy link
Member

@brjohnstmsft brjohnstmsft commented Feb 9, 2018

Two of the JsonSerializationTests modify JsonConvert.DefaultSettings. They do this in order to validate that SafeJsonConvert does not rely on these settings.

Before this change, these tests would install a custom JSON converter and contract resolver that always throw. Unfortunately, other aspects of the test infrastructure rely on DefaultSettings, so this would sometimes result in unexpected exceptions being thrown.

The solution is to weaken the effect of changing DefaultSettings. Now, the SafeJsonConvert tests install a custom converter for their own Model class that produces incorrect results. Because it's targeted at that class specifically, it should have no side effects on other code that relies on DefaultSettings.

FYI @shahabhijeet @dsgouda

Description


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

SDK Generation Guidelines

  • If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
  • The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as the commitid of your swagger spec or link to the swagger spec, used to generate the code.
  • The *.csproj and AssemblyInfo.cs files have been updated with the new version of the SDK.

Two of the JsonSerializationTests modify JsonConvert.DefaultSettings. They do
this in order to validate that SafeJsonConvert does not rely on these
settings.

Before this change, these tests would install a custom JSON converter and
contract resolver that always throw. Unfortunately, other aspects of the test
infrastructure rely on DefaultSettings, so this would sometimes result in
unexpected exceptions being thrown.

The solution is to weaken the effect of changing DefaultSettings. Now, the
SafeJsonConvert tests install a custom converter for their own Model class
that produces incorrect results. Because it's targeted at that class
specifically, it should have no side effects on other code that relies on
DefaultSettings.
@shahabhijeet shahabhijeet merged commit 1e04a05 into Azure:psSdkJson6 Feb 10, 2018
@brjohnstmsft brjohnstmsft deleted the fix-clientruntime-tests branch February 10, 2018 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants