[英]What's the best way to run unit tests against an ASP.NET REST Web API server
We have an ASP.NET Web API server app that provides a REST API. We have an ASP.NET Web API server app that provides a REST API.
What I want is pretty simple.我想要的很简单。 That when our unit tests run, and I prefer NUnit but can do the Microsoft test framework, that it would fire up the server app.
当我们的单元测试运行时,我更喜欢 NUnit 但可以执行 Microsoft 测试框架,它会启动服务器应用程序。 And I then have unit tests written that make REST calls and assert the returned response.
然后我编写了单元测试,使 REST 调用并断言返回的响应。
Which leaves the questions:这留下了问题:
You described a integration tests in asp.net core and there is quite good documentation for that starting with this您在 asp.net 内核中描述了一个集成测试,并且从这个开始有相当好的文档
You need to basically setup a host inside your IntegrationTests solution using Generic host and then all points 1-4 are covered您基本上需要使用通用主机在您的 IntegrationTests 解决方案中设置一个主机,然后涵盖所有点 1-4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.