3
votes

I'm using TeamCity 5 with Git VCS and Visual Studio 2010 SLN build runner.

My solution has a class library proj containing a number of XUnit 1.5 tests. The post build event on this project runs the tests

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

This works fine for running all my tests on my dev machine, and runs fine on the TeamCity build agent.

However, I recently added a new XUnit test function to this project, committed it to github, which was picked up by TeamCity and a build was run. But the new test was not included in the run.

It appears that the source is checked out to a different directory (e.g. c:\checkedoutsource) to my git repository (c:\my_source), and when the SLN build runner builds my solution, the post build event 'run tests' is targeting the c:\checkedoutsource\bin\debug\MyTestProj.dll and not c:\my_source\bin\debug\MyTestProj.dll

Anyone have any suggestions of how to get TeamCity to build my test project and run the post build event against the newly created test assembly?? (without writing mahoosive MSBuild script files).

i.e. is it possible to set visual studio variables such as $(SolutionDir) in the build runner?

Hope that made sense, thanks

1

1 Answers

1
votes

In our project we run tests from separate target in *.msbuild file:

<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>

And we configure TeamCity to execute two targets: Build, RunTests.

The caveat is that our projects are copying them selves in after-build event to "well-known" directory, but that directory is relative.

Hope this helps.