简体   繁体   中英

Run MSTest unit tests on a project when it needs to be running

I am looking to run some automated RestSharp API tests in Continuous integration.

Right now, the application API is running in it's own project, which is set as a Startup Project. The Web App is running in a separate project. And when they are both run manually from Visual Studio, the app's UI can be manually tested against the locally running API (That's just for reference, I only need the API project to run for my tests to work).

So right now, to run my automated API tests as I script them, I start the API project to get the API up and running locally, then open a new window of Visual Studio, and run my MSTests from there.

My question is, how do I get the API project up and running automatically, so the tests can be run against the API? Can I start tests, while the API project is actively running in Visual Studio?

Mainly, how can I run these API tests in Continuous Integration, if the API needs to be started up in a separate VS window every time?

Sorry for the fairly broad question, I am a test automation engineer, and not an API developer. A pointer in the right direction would be great.

You can deploy the Web API to IIS (or IIS Express). In that way, it would be running in the background rather than launched from Visual Studio. The CI tool would then update the deployment after it creates a new build, but before it runs the tests. I would start with the documentation for whatever CI/CD system you are using, but assuming you're using TFS, here is a reasonable starting point: https://www.visualstudio.com/en-us/docs/build/apps/ . There are links from that page for deployment and CI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM