简体   繁体   English

在部署的站点上使用teamcity运行Nunit测试

[英]Run Nunit tests using teamcity on deployed site

I have configured TeamCity with Git to get my ASP.NET MVC project. 我已经用Git配置了TeamCity以获取我的ASP.NET MVC项目。 I added tests with NUnit as the last step. 最后一步,我添加了NUnit的测试。

But one test checks method which works only on the machine where my project is deployed (access restriction peculiarity). 但是一种测试检查方法仅适用于部署了我的项目的机器(访问限制特殊)。

So test fails because it tests code that is being deployed on TeamCity deploying agent machine. 因此测试失败,因为它测试正在TeamCity部署代理计算机上部署的代码。 I have to run tests against deployed environment somehow. 我必须以某种方式针对已部署的环境运行测试。

Can I somehow make my tests check functionality of projects on the deployed to machine site or run dll with tests from the directory where the site has been deployed to? 我能以某种方式使我的测试检查部署到计算机站点上的项目的功能,还是通过将站点部署到的目录中的测试运行dll?

One approach would be to mark that test [Explicit] so that it only runs if you select it. 一种方法是标记该测试[Explicit],以便仅在您选择它后才运行。 That would basically mean you could only run it manually. 这基本上意味着您只能手动运行它。

Another approach is to use a unique category on that test and exclude it in your TC runs. 另一种方法是在测试中使用唯一类别,并将其排除在TC运行中。 When you don't exclude it on the command-line, it will be run. 当您不在命令行中排除它时,它将运行。

You could combine the two approaches as [Explicit, Category("Deployed")] if you like. 如果愿意,可以将两种方法组合为[Explicit,Category(“ Deployed”))。 In that case, you would have to include the Deployed category in your run using the --include option in NUnit V2 or --where in NUnit V3. 在这种情况下,您必须在运行中使用NUnit V2中的--include选项或NUnit V3中的--where选项将Deployed类别包括在内。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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