Last post Apr 17, 2020 12:15 PM by mgebhard
Apr 16, 2020 11:03 PMemail@example.com|LINK
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. And I then have unit tests written that make REST calls and assert the returned response.
Which leaves the questions:
thanks - dave
Apr 17, 2020 06:00 AM|DA924|LINK
When is a test not a unit test?
If you want to do integration testing of a WebAPI that's one thing, but a unit test of a Web service that's what a WebAPI is it is a Web service, I would have to question it.
Apr 17, 2020 11:44 AMfirstname.lastname@example.org|LINK
Sorry - integration tests. I use "unit tests" as shorthand for both since I use the same unit test framework for both.
Apr 17, 2020 12:15 PM|mgebhard|LINK
While I do not agree with this testing approach, I feel the best solution is deploying the Web API application to localhost IIS. Then run the integration tests from localhost rather than IIS Express. The deployment strategy is up to you. For example,
you could manually deploy a build or deploy the application every time there is a build. See the project properties build events to move files to the configured application root directory.
Anyway, the idea is localhost IIS is always running on the configured port so there is no need to start IIS.