5
votes

I'm trying to run MS tests from the build folder on the TeamCity.

Main reason is that our application uses several configuration files (csv files with 'Copy to Output Directory' option set), that are loaded from its run folder. Those are not test files, but required application files, so using MSTest deploy attribute is not an option.

Locally, R# and VS2013 run tests correctly, on the TeamCity (8.1) I get an error - csv files are missing.

I tried using .runsettings file ("Build Step configuration/MSTest run configuration file") to specify <DeploymentEnabled>False</DeploymentEnabled> however MSTest (12.0.21005.1) returns this error:

"The file 'C:\TeamCity\buildAgent\work\d6160ab253397620\tests.runsettings' has unknown format and cannot be converted to the current version."

The file is dead simple (copied from msdn):

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <!-- MSTest adapter -->
  <MSTest>
    <MapInconclusiveToFailed>True</MapInconclusiveToFailed>
    <CaptureTraceOutput>false</CaptureTraceOutput>
    <DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
    <DeploymentEnabled>False</DeploymentEnabled>
  </MSTest>
</RunSettings>

I'm banging my head over this for the last 2 hours and I can't believe, that something so simple is so hard to accomplish using MSTest.

[Edit]

It seems that the file should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<TestSettings
  id="b8968a45-0b6a-40a9-bcf7-7573da114965"
  name="MSTest"
  enableDefaultDataCollectors="false"
  xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description><!--_locID_text="Description1"-->These are default test settings for a local test run.</Description>
  <Deployment enabled="false" />
</TestSettings>

...but it still doesn't work: tests are run in a custom folder and csv files are not copied.

2
I have the exact same issue. Did you find a solution by any chance?Pedro
I am using the edited version of your test.runsettings and it is now working for me on TC 9.0.3 - Still confused as lots of references to using <DeploymentEnabled>False</DeploymentEnabled> and yet in your working xml file it is <Deployment enabled="false" />wal

2 Answers

1
votes

Pawel, just stumbled on your question and:

  1. Tried yours updated version of .runsettings - it is working OK
  2. If TC does not see CSV files maybe add following key to msbuild script - after compile:

<Copy SourceFiles="$(MSBuildProjectDirectory)\bin\FROM\.config"  DestinationFolder="$(MSBuildProjectDirectory)\BuildOutput\TO\.config"></Copy>
0
votes

You say you can't use the MSTest deploy attribute, but I had the same problem and using the DeploymentItem attribute solved it.

My deployment item is not a CSV, but an auto-generated DLL (XmlSerializer DLL) which is copied to the output folder during build and needs to be in the Test run folder.

In Visual Studio I also used the RunSettings option of <DeploymentEnabled>False</DeploymentEnabled>, but couldn't find a way to make TeamCity use this file.

So finally I added a DeploymentItem to each TestClass and that solved the problem.

The DeploymentItem just needs to contain the name of the file you want to copy since it is relative to the build output folder and copies the item to the Test Run Folder.

In your case I guess it would be something like: [DeploymentItem("Data.csv")]