MSTest的命令行设置 [英] MSTest Command Line Settings

查看:253
本文介绍了MSTest的命令行设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要能够通过一个服务器地址进入MSTest的命令行为我们的测试套件,它是由连续的TeamCity集成(CI)软件调用

We need to be able to pass a server address into MSTest command line for our testing suite that is invoke by TeamCity Continuous Integration (CI) software.

previously我们的#if常量在C#中的单元测试,这使得中的MSBuild的变化所造成的。

Previously we created #if constants in C# unit tests, which made the change in MSBuild.

有没有更好的办法?这种方式似乎pretty的哈克。

Is there a better way? This way seems pretty hacky.

有没有一种方法来创建配置文件,并传递参数要在MSTest的使用?

Is there a way to create config files and pass arguments to be used within MSTest?

推荐答案

我使用的的app.config 在我的测试项目文件来配置我的测试。源代码控制包含用于在TeamCity的运行试验在app.config。

I use an app.config file in my test project to configure my tests. Source control contains the app.config used in TeamCity to run the tests.

在编译的app.config被复制到bin文件夹,并重新命名为[组件名称]的.config。然后,您可以从您的测试code通过的 ConfigurationManager中

On compilation the app.config is copied to the bin folder and renamed to [assembly-name].config. You can then access any settings in the .config file from your test code through the ConfigurationManager.

在开发系统时,config文件被定制在其上运行什么都本地测试服务器开发人员正在使用的测试。

On development systems, the .config file is customized to run tests against what ever local test server the developer is using.

我觉得这是最干净的方法还没有,因为它记录了如何测试配置的源代码控制。

I find this the cleanest approach yet, because it records how tests are configured in source control.

如果你需要更多的灵活性,你可以设置一个额外的生成步骤中的TeamCity根据需要使用从自定义的MSBuild脚本一些XML转换或字符串替换修改config文件。

If you need more flexibility you could setup an additional build step in TeamCity to modify the .config file as needed using some XML transforms or string replacements from a custom MSBuild script.

这篇关于MSTest的命令行设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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