KEMBAR78
Functional REST API testing in ASP.NET Core | PPTX
Functional REST API testing
in ASP.NET Core
Does anyone know why the
API isn’t working anymore?
Because api/product/1 is not the
same as api/products/1
SystemTests
Integration
Unit
FunctionalTests
How to test controllers and
actions
How to test controllers and
actions… Not!
What we DO want to test
• The API contract
• Resource access (routing)
• Accepted verbs
• Response codes
• Response format/representation
• API versioning and backwards compatibility
• Validation
• Access control
How it used to be back in the
day
Nancy had the right ideea
But we just usedWebApi and
Postman
WebApi self hosting with
HttpSelfHostServer
Why not start a host and server
the API during tests?
OWIN, Katana andTestServer
Nowadays – ASP.NET Core 2.1
Pick your testing framework
Add some nuget packages
Start writing tests (DEMO)
https://github.com/sdamian/RestApiTestingDemo
Separate the API (unit) tests
from your business logic tests
Friends don’t let friends use
untested API’s
Thank you!

Functional REST API testing in ASP.NET Core

Editor's Notes

  • #3 I „fixed” some resource names Oops I don’t remember changing that Typing in the wrong window
  • #11 htps://github.com/NancyFx/Nancy/wiki/Testing-your-application
  • #16 Open web interface for dotnet Katana was Microsoft’s implementation that eventually evolved into asp.net core
  • #19 The extension methods are in microsoft.aspnet.webapi.client
  • #21 If you want isolated ”unit” tests