Roman Alexis Anastasini
Using code generation for test automation – the fancy way
#1about 3 minutes
Setting up NSwag for OpenAPI documentation in .NET
Replace the default Swashbuckle with NSwag to generate OpenAPI specifications for a new .NET web application.
#2about 3 minutes
Automating swagger.json generation on every build
Configure the project file to automatically run the NSwag command-line tool after each build to create an up-to-date swagger.json file.
#3about 4 minutes
Generating a typed C# client for the test project
Use the generated swagger.json file to automatically create a strongly-typed C# HTTP client within the test project.
#4about 4 minutes
Using the generated client for robust API-level tests
Write API-level tests that consume the generated client, ensuring that any API signature changes result in compile-time errors.
#5about 7 minutes
Testing DTOs, validation, and API error handling
Leverage the generated client and DTOs to easily test complex validation rules, serialization formats, and API exception handling.
#6about 4 minutes
Achieving high test coverage with API-level tests
Focusing on API-level tests provides high code coverage and confidence for refactoring while reducing the effort spent on traditional unit tests.
#7about 2 minutes
Key lessons learned from this testing approach
This approach requires writing precise controller code and evolving from slow Docker-based databases to faster in-memory databases for tests.
#8about 1 minute
Q&A: Why API tests can be more efficient than unit tests
API-level tests reduce the developer time spent writing and maintaining numerous small unit tests, especially as the codebase grows.
#9about 1 minute
Q&A: Managing code coverage targets and exceptions
Set a high but realistic code coverage target like 90-95% to avoid writing useless tests for unreachable edge cases.
#10about 2 minutes
Q&A: Automating checks for breaking API changes
A potential improvement is to add a CI step that tests the new API version against a client generated from a previous API version.
#11about 2 minutes
Q&A: Managing test state and database setup
Use the web application factory to manage test setup, such as spinning up an in-memory database and seeding it with data for each test class.
#12about 2 minutes
Q&A: Mocking external service dependencies in tests
Isolate the API under test by mocking external service calls through interfaces, reserving full integration tests for the CI pipeline.
#13about 3 minutes
Q&A: The accidental discovery of this testing workflow
The idea to use the generated client in tests originated from the initial goal of providing an easy-to-use client for other consumer APIs.
Related jobs
Jobs that call for the skills explored in this talk.
Power Plus Communications
Mannheim, Germany
Intermediate
Senior
Python
Automated Testing
+1
Eltemate
Amsterdam, Netherlands
Intermediate
Senior
TypeScript
Continuous Integration
+1
Matching moments
02:49 MIN
Using AI to overcome challenges in systems programming
AI in the Open and in Browsers - Tarek Ziadé
09:10 MIN
How AI is changing the freelance developer experience
WeAreDevelopers LIVE – AI, Freelancing, Keeping Up with Tech and More
04:05 MIN
How AI code generators have become more reliable
AI in the Open and in Browsers - Tarek Ziadé
05:55 MIN
The security risks of AI-generated code and slopsquatting
Slopquatting, API Keys, Fun with Fonts, Recruiters vs AI and more - The Best of LIVE 2025 - Part 2
03:16 MIN
Improving the developer feedback loop with specialized tools
Developer Time Is Valuable - Use the Right Tools - Kilian Valkhof
04:09 MIN
The emerging market for fixing AI-generated code
Devs vs. Marketers, COBOL and Copilot, Make Live Coding Easy and more - The Best of LIVE 2025 - Part 3
05:12 MIN
How to build structure and culture without killing agility
From Data Keeper to Culture Shaper: The Evolution of HR Across Growth Stages
03:31 MIN
The value of progressive enhancement and semantic HTML
WeAreDevelopers LIVE – You Don’t Need JavaScript, Modern CSS and More
Featured Partners
Related Videos
Testing .NET applications a Tool box for every developer
Alexandre Borges
Specifications as the better way of software development
Artem Manchenkov
Write tests you love, not hate
Jens Happe
How to add test automation to your project: The good, the bad, and the ugly
Augustin Gottlieb
Continuous testing - run automated tests for every change!
Christian Kühn
Are you still programming unit tests or already generating?
Johannes Bergsmann & Daniel Bauer
The 2025 State of JavaScript Testing
Daniel Afonso
What you can learn from an open-source project with 500 million downloads
Dennis Doomen
Related Articles
View all articles



From learning to earning
Jobs that call for the skills explored in this talk.


MARKT-PILOT GmbH
Stuttgart, Germany
Remote
€75-90K
Senior
Java
Angular
TypeScript


Engineering Ltd
Stonehouse, United Kingdom
£45-80K
GIT
Azure
DevOps
Python
+6

Epam Systems, Inc.
Zürich, Switzerland
Selenium
Cucumber
TypeScript
Tricentis Tosca Testsuite

Sedenius Engineering GmbH
Dresden, Germany
API
JUnit
Python
Gitlab
Docker
+6



primion Technology GmbH
Swifterbant, Netherlands
Remote
Azure
Gitlab
Terraform
TypeScript
+1