在运行单元测试之前复制到teamcity的目录 [英] copying to teamcity's out directory before running unit tests

查看:266
本文介绍了在运行单元测试之前复制到teamcity的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的情况是,我终于完成配置TeamCity的CI。我得到它运行我的单元测试与一些友好的帮助SO

So my situation is that I finally finished configuring TeamCity for CI. I got it to run my unit tests with some friendly help on SO.

但是,许多单元测试失败,因为在构建并准备运行后,需要在unittests.dll旁边有一个配置文件。

However, many unit tests fail because there needs to be a config file alongside the unittests.dll once it's built and ready to run.

我写了一个简单的命令行步骤:

I've written a simple Command Line step with:

copy %system.teamcity.build.checkoutDir%\xx.configfile <destination>

目标是问题,我需要它<

The destination is the problem, I need it to be the Out directory teamcity creates.

TC创建 SYSTEM_< machinename> < datetime> \OUT 。示例:

C:\TeamCity\buildAgent\temp\buildTmp\SYSTEM_GIDEON 2015-07-02 16_51_09\Out

在我有unittests.dll,我想复制我的配置文件。在命令行脚本中我可以使用什么环境变量或(其他)?

In there is my unittests.dll and I want to copy my config file there. What environment var or (anything else) can I use in the command line script?

(1)构建测试是一个步骤然后我想运行(2)复制配置步骤然后(3)运行测试。在步骤(1)后,我有 xxx\xxx\Out 目录,我需要一些变量的目录。

The (1) Build Tests is a Step then I want to run the (2) Copy Config Step Then (3) Run Tests. After step (1) I have that xxx\xxx\Out directory and I need that directory from some variable.

我正在使用Teamcity 9.0.2

I'm using Teamcity 9.0.2

推荐答案

您的问题与TeamCity无关我不认为,它与MSTest的工作方式有关。您需要.config文件成为 DeploymentItem ,并将您的测试部署到MSTest将运行测试的目录中。

Your problem is not to do with TeamCity I don't think, it's to do with the way that MSTest works. You need your .config file to be a DeploymentItem and have your tests deploy it to the directory that MSTest will run the tests in.

要老实说我很惊讶,你没有在本地运行这个问题,它让我认为,如果你没有在本地机器上看到这个问题,你必须使用一些其他测试运行程序(如ReSharper)运行测试。

To be honest I'm surprised that you don't have this problem running locally, and it makes me think that you must be using some other test runner (like ReSharper) to run the tests if you have not seen this problem on your local machines.

这篇关于在运行单元测试之前复制到teamcity的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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