在部署的站点上使用teamcity运行Nunit测试 [英] Run Nunit tests using teamcity on deployed site

查看:330
本文介绍了在部署的站点上使用teamcity运行Nunit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置TeamCity与Git来获取我的ASP.NET MVC项目。
我添加了NUnit测试作为最后一步。

I have configured TeamCity with Git to get my ASP.NET MVC project. I added tests with NUnit as the last step.

但是一个测试检查方法只在我的项目部署的机器上工作(访问限制特殊性) 。

But one test checks method which works only on the machine where my project is deployed (access restriction peculiarity).

所以测试失败,因为它测试部署在TeamCity部署代理机上的代码。我必须对部署的环境以某种方式运行测试。

So test fails because it tests code that is being deployed on TeamCity deploying agent machine. I have to run tests against deployed environment somehow.

我可以用某种方式使我的测试检查项目的功能在部署到机器网站或运行dll与测试从目录该网站已部署到

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?

推荐答案

一种方法是标记该测试[显式]选择它。这基本上意味着你只能手动运行它。

One approach would be to mark that test [Explicit] so that it only runs if you select it. That would basically mean you could only run it manually.

另一种方法是在测试中使用一个唯一的类别,并在你的TC运行中排除它。

Another approach is to use a unique category on that test and exclude it in your TC runs. When you don't exclude it on the command-line, it will be run.

您可以将这两种方法组合为[Explicit,Category(Deployed)]如果你喜欢。在这种情况下,您必须使用NUnit V2中的--include选项或NUnit V3中的--where在运行中包括已部署的类别。

You could combine the two approaches as [Explicit, Category("Deployed")] if you like. 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.

这篇关于在部署的站点上使用teamcity运行Nunit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆