ASP.NET Core › API Versioning

How would you implement automated testing that verifies deprecated API versions still function correctly while newer versions are actively developed?

Advanced

Answer

A regression test suite organized by version (parameterized integration tests running the same test scenarios against each supported version's endpoint, using WebApplicationFactory with version headers/URLs varied per test case) ensures that ongoing development on newer versions doesn't accidentally break older, still-supported versions -- critical since deprecated doesn't mean 'can silently break', only 'scheduled for eventual removal', and consumers still relying on it deserve continued correctness guarantees until the announced removal date.
[Theory]
[InlineData("1.0")]
[InlineData("2.0")]
public async Task GetProduct_ReturnsCorrectShape_ForVersion(string version) {
    var client = _factory.CreateClient();
    var response = await client.GetAsync($"/api/v{version}/products/1");
    response.EnsureSuccessStatusCode();
    // assert version-appropriate response shape
}
Real-world example A CI pipeline runs the full regression suite against both v1 (deprecated but still supported) and v2 (actively developed) on every pull request, catching a case where a v2-focused refactor accidentally introduced a shared-code regression that broke v1's still-supported behavior.

Common follow-ups: How do you avoid excessive test duplication across many supported versions?;At what point does a deprecated version get removed from the regression suite too?