A practical guide to setting up a test matrix in XUnit for .NET projects, motivated by adding System.Text.Json support to the Marten library alongside Newtonsoft Json.NET. The approach uses environment variables to select the active serializer, a custom XunitTestFramework to initialize settings before tests run, and a custom Fact attribute with a discoverer to conditionally skip tests unsupported by a given serializer. The post also shows how to wire up the matrix in GitHub Actions using a strategy matrix that passes the serializer type as an environment variable.

7m read timeFrom event-driven.io
Post cover image
27 Impressions