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

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

问题描述

所以我的情况是我终于完成了为 CI 配置 TeamCity.我得到它 在 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>

destination 是问题所在,我需要它是 teamcity 创建的 Out 目录.

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

TC 创建 SYSTEM_;<日期时间>OUT.一个例子:

TC creates SYSTEM_<machinename> <datetime>OUT. An example:

C:TeamCityuildAgent	empuildTmpSYSTEM_GIDEON 2015-07-02 16_51_09Out

里面有我的 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) 之后,我有了那个 xxxxxxOut 目录,我需要某个变量中的那个目录.

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 xxxxxxOut 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 的 out 目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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