你的位置: 码友网首页 / 资讯源列表 / Self-hosted integration tests in ASP.NET

关于[Self-hosted integration tests in ASP.NET]的摘要:

In 2020 I developed a sizeable code base for an online restaurant REST API. In the spirit of outside-in TDD, I found it best to test the HTTP behaviour of the API by actually interacting with it via HTTP. Sometimes ASP.NET offers more than one way to achieve the same end result. For example, to return 200 OK, you can use both OkObjectResult and ObjectResult. I don't want my tests to be coupled to such implementation details, so by testing an API via HTTP instead of using the ASP.NET object model, I decouple the two. You can easily self-host an ASP.NET web API and test it using an HttpClient. In this article, I'll show you how I went about it.

原文地址: https://blog.ploeh.dk/2021/01/25/self-hosted-integration-tests-in-aspnet/

收录时间: 2021-01-26 浏览量: 1346 分类: ASP.NET

| 0 收藏 | 0