[英]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. 我希望在持续集成中运行一些自动化的RestSharp API测试。
Right now, the application API is running in it's own project, which is set as a Startup Project. 现在,应用程序API正在其自己的项目中运行,该项目被设置为“启动项目”。 The Web App is running in a separate project.
Web App在单独的项目中运行。 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).
而且,当它们都从Visual Studio手动运行时,可以针对本地运行的API手动测试应用程序的UI(这仅供参考,我只需要运行API项目即可运行我的测试)。
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. 因此,现在,要在编写自动化API测试的脚本时运行它们,我将启动API项目以启动API并在本地运行,然后打开Visual Studio的新窗口,并从此处运行MSTest。
My question is, how do I get the API project up and running automatically, so the tests can be run against the API? 我的问题是,如何使API项目自动启动并运行,以便可以针对API运行测试? Can I start tests, while the API project is actively running in Visual Studio?
当API项目在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? 如果每次需要在单独的VS窗口中启动API,主要是如何在Continuous Integration中运行这些API测试?
Sorry for the fairly broad question, I am a test automation engineer, and not an API developer. 很抱歉,我是一个测试自动化工程师,而不是API开发人员。 A pointer in the right direction would be great.
指向正确方向的指针会很棒。
You can deploy the Web API to IIS (or IIS Express). 您可以将Web API部署到IIS(或IIS Express)。 In that way, it would be running in the background rather than launched from Visual Studio.
这样,它将在后台运行,而不是从Visual Studio启动。 The CI tool would then update the deployment after it creates a new build, but before it runs the tests.
CI工具将在创建新版本之后但在运行测试之前更新部署。 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/ .
我将从任何正在使用的CI / CD系统的文档开始,但是假设您正在使用TFS,这是一个合理的起点: https : //www.visualstudio.com/zh-cn/docs/build/apps / 。 There are links from that page for deployment and CI.
该页面上有用于部署和CI的链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.