Summary
Recent regressions caught in Microsoft.Extensions.Configuration.Binder have shown that the ConfigurationBinder test coverage is not thorough enough. As type support grows and changes in the Configuration Binder, it makes sense to add an extensible test theory that types can be easily added to. System.Text.Json created a test system for serialization that would conceptually translate nicely over to the Configuration Binder. Here's a brief summary of how it works for the serialization tests:
JSON Serialization Tests
- Create a folder of test classes to feed into the test case. These classes contain a data string to be fed into the serializer, as well as
Initialize() and Verify() methods to populate class properties and assert that expected output occurs.
- Expose the test classes as a public
IEnumerable<object[]>.
- Feed the
IEnumerable<object[]> as Xunit [MemberData()], as seen here.
Proposal
If a solution is found that replicates the Configuration Binder tests using this methodology, it will be much easier to test a large variety of types in an extensible way. The current test format (example) instantiates a Dictionary<string, string> as a payload for the ConfigurationBuilder. There may be a way to rewrite this process when porting over the serializer test logic to minimize boilerplate for adding new types.
Summary
Recent regressions caught in
Microsoft.Extensions.Configuration.Binderhave shown that theConfigurationBindertest coverage is not thorough enough. As type support grows and changes in the Configuration Binder, it makes sense to add an extensible test theory that types can be easily added to.System.Text.Jsoncreated a test system for serialization that would conceptually translate nicely over to the Configuration Binder. Here's a brief summary of how it works for the serialization tests:JSON Serialization Tests
Initialize()andVerify()methods to populate class properties and assert that expected output occurs.IEnumerable<object[]>.IEnumerable<object[]>as Xunit[MemberData()], as seen here.Proposal
If a solution is found that replicates the Configuration Binder tests using this methodology, it will be much easier to test a large variety of types in an extensible way. The current test format (example) instantiates a
Dictionary<string, string>as a payload for theConfigurationBuilder. There may be a way to rewrite this process when porting over the serializer test logic to minimize boilerplate for adding new types.