简体   繁体   English

需要在项目上运行项目时运行MSTest单元测试

[英]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.

相关问题 如何并行运行单元测试(MSTest)? - How to run unit tests (MSTest) in parallel? 使用TFS 2008将单元测试作为CI的一部分运行时,MsTest失败 - MsTest fails when running unit tests as part of CI using TFS 2008 在与名称模式匹配的项目中使用mstest运行所有单元测试 - Run all unit tests with mstest in projects matching a name pattern 在Visual Studio中运行应用程序时如何运行单元测试 - How to run unit tests when running the application in visual studio VS中的Mstest Run忽略测试 - Mstest Run ignored tests in VS 从VS2008内部运行单元测试与在命令行上使用mstest - Running unit tests from within VS2008 vs using mstest on the command line 在Visual Studio单元测试(MSTest)中对项目中的所有测试进行每次测试之前,是否可以执行初始化代码? - Is there a way to execute initializer code before each test in Visual Studio Unit Testing (MSTest) for all tests in a project? 如何运行mstest单元测试,以便基础数据库有时间正确构建? - How to run mstest unit tests so that an underlying database has time to build properly? 在Visual Studio中运行单元测试时出现FileLoadException - FileLoadException when running unit tests in visual studio 如何使用MSTest从测试项目的输出文件夹以外的文件夹运行测试? - How can I run tests from a folder other than the test project's output folder, using MSTest?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM