3

我将 TeamCity 5 与 Git VCS 和 Visual Studio 2010 SLN 构建运行器一起使用。

我的解决方案有一个类库 proj,其中包含许多 XUnit 1.5 测试。此项目的构建后事件运行测试

$(SolutionDir)libs\XUnit-1.5\xunit.console.exe $(SolutionDir)MyTestProj\$(OutDir)\MyTestProj.dll

这适用于在我的开发机器上运行我的所有测试,并且在 TeamCity 构建代理上运行良好。

但是,我最近在这个项目中添加了一个新的 XUnit 测试功能,将其提交到 github,它被 TeamCity 拾取并运行了一个构建。但新的测试并未包含在运行中。

似乎源代码已签出到我的 git 存储库 (c:\my_source) 的不同目录(例如 c:\checkedoutsource),并且当 SLN 构建运行器构建我的解决方案时,构建后事件“运行测试”的目标是c:\checkedoutsource\bin\debug\MyTestProj.dll 而不是 c:\my_source\bin\debug\MyTestProj.dll

任何人都对如何让 TeamCity 构建我的测试项目并针对新创建的测试程序集运行构建后事件有任何建议?(无需编写强大的 MSBuild 脚本文件)。

即是否可以在构建运行器中设置诸如 $(SolutionDir) 之类的 Visual Studio 变量?

希望有道理,谢谢

4

1 回答 1

1

在我们的项目中,我们从 *.msbuild 文件中的单独目标运行测试:

<Project defaulttargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <UsingTask AssemblyFile="Library\xUnit\xunit.runner.msbuild.dll" TaskName="Xunit.Runner.MSBuild.xunit"/>
    <Target Name="Build">
        <MSBuild Projects="MyProject.sln" Properties="Configuration=Release"/>
    </Target>
    <Target Name="RunTests">
        <xunit assembly="Tests\Output\MyProject.Tests.dll" />
    </Target>
</Project>

我们将 TeamCity 配置为执行两个目标:BuildRunTests

需要注意的是,我们的项目在构建后事件中将它们自身复制到“知名”目录,但该目录是相对的。

希望这可以帮助。

于 2011-02-28T14:31:05.110 回答