World Congress 2021 Jun 28, 2021

Using code generation for test automation – the fancy way

Roman Alexis Anastasini

Stop wasting hours on brittle unit tests. Learn how auto-generating C# HTTP clients from OpenAPI specs creates lightning-fast, robust API tests with zero boilerplate.

Pause
Mute Enter Fullscreen
#1 about 4 min

Replacing Swashbuckle with NSwag for API testing

Swapping Swashbuckle for NSwag documentation streamlines the initial setup process for generating API clients.

#2 about 3 min

Generating a Swagger JSON file during the build process

Configuring the project file automatically generates an OpenAPI specification immediately after the build process completes.

#3 about 3 min

Creating and configuring the unit test project

Adding an xUnit test project and referencing Microsoft MVC packages prepares the environment for automated testing.

#4 about 2 min

Generating a C# API client from the Swagger JSON

Automating C# client generation during the build phase seamlessly provides typed API endpoints to the test project.

#5 about 4 min

Writing API-level HTTP tests instead of unit tests

Replacing cumbersome unit tests with API-level tests using generated HTTP clients significantly broadens functional test coverage.

#6 about 1 min

Handling API endpoint changes safely with generated clients

Automatically generated clients provide compile-time safety by instantly flagging any renamed or modified HTTP endpoints.

#7 about 6 min

Validating requests and responses using data transfer objects

Leveraging generated data transfer objects enables built-in model validation and straightforward serialization inside test setups.

#8 about 3 min

Testing edge cases and validation errors with API exceptions

Asserting against automatically thrown API exceptions provides a reliable way to verify bad requests and validation errors.

#9 about 4 min

Achieving high test coverage efficiently with API tests

Utilizing automated API integration checks allows teams to efficiently reach minimum statement coverage thresholds.

#10 about 3 min

Creating precise controller code for accurate client generation

Writing explicit controller configurations ensures accurate OpenAPI specifications and reliable client generation.

#11 about 1 min

Switching from Docker databases to in-memory databases

Moving from resource-heavy Docker containers to in-memory databases dramatically reduces test execution times.

#12 about 3 min

Understanding unit testing overhead and code coverage metrics

Maintaining granular unit tests consumes excessive resources compared to using broad API-level integration checks.

#13 about 3 min

Detecting breaking API changes in CI pipelines

Running integration tests with older generated clients helps prevent accidental backward compatibility breaks in CI pipelines.

#14 about 2 min

Managing test state and setup dependencies

Utilizing web application factories and abstract base classes cleanly handles state initialization for individual test classes.

#15 about 2 min

Mocking external service dependencies in API tests

Abstracting external dependencies behind mocked interfaces isolates API tests while preserving full coverage during integration runs.

#16 about 3 min

Unexpected test automation benefits and execution speed improvements

Reusing API clients intended for external consumers significantly reduces test code verbosity and improves overall productivity.

Matching moments

1:25 min

Testing API endpoints visually using Swagger UI

Alex Soto Alex Soto · World Congress 2022

1:16 min

Automating documentation and code generation with OpenAPI standards

James Seconde · World Congress 2023

7:44 min

Bootstrapping a test-driven asp.net web api

Alex Banul · LIVE

3:18 min

Implementing contract-first API design with OpenAPI and SwaggerHub

Christoph Ruggenthaler · LIVE

1:58 min

Implementing automated API and workflow testing pipelines

David Tielke David Tielke · World Congress 2026 Europe

3:50 min

Applying test-driven principles to APIs

Sascha Depold +1 · World Congress 2021

Upcoming sessions on this topic

Open session

World Congress 2026 North America

September 25, 2026 · 10:20–10:50

Stage 9

Testing React Backends Like a Pro: Mocking Databases with SQLite

David Morris

Solution Architect at Leidos

David Morris
Open session

World Congress 2026 North America

September 24, 2026 · 13:30–14:00

Stage 1

How AI Agents Tripled Our Test Coverage on a 1.8M-Line iOS Codebase

Kush Agrawal

Staff Software Engineer, Platform

Kush Agrawal
Open session

World Congress 2026 North America

September 24, 2026 · 12:00–12:05

Outdoor Stage

Production runtime for Enterprise AI agents

Aditya Rohit

Swytchcode, Aditya, Founder and CEO

Aditya Rohit
Open session

World Congress 2026 North America

September 25, 2026 · 12:20–12:50

Stage 9

Designing APIs That Survive AI Agents at Scale

Phani Pendurthi

Mastercard, Principal Software Engineer

Phani Pendurthi
Open session

World Congress 2026 North America

September 25, 2026 · 11:40–12:10

Stage 2

Reinventing Testing Practices in the AI Era

Eric Deandrea

Java Champion & Senior Principal Software Engineer at IBM

Eric Deandrea
Open session

World Congress 2026 North America

September 24, 2026 · 14:10–14:40

Stage 9

One Repo, One Strategy: Scalable Full-Stack Testing in a Monorepo World

Bartosz Leczycki, Paweł Matynia

Bartosz Leczycki
Paweł Matynia