Skip to content

Instantly share code, notes, and snippets.

@codito
Last active August 29, 2015 14:03
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save codito/e430d3b155b9af675ba9 to your computer and use it in GitHub Desktop.
Save codito/e430d3b155b9af675ba9 to your computer and use it in GitHub Desktop.
Running Windows Phone unit tests in team build (TFS)

Running Windows Phone unit tests in team build (TFS)

Prerequisites:

  • Build Agent needs to run a physical x64 Windows 8.1 based machine to be able to run Phone emulators
  • Setup build agent to run as an interactive process and enable it to run unit tests (obtain developer license). Check this MSDN page for more help on this.
  • Install Visual Studio 2013 + Update 2 (with support for Phone development) on Build Agent

Once you have these, you can use custom scripts in TFS 2013 build definition to run phone tests using vstest.console command line. See the script RunPhoneTests.bat

Editing build definition to run script

Build Definition Configuration

:: Run Windows Phone Tests using vstest.console.exe in TFS 2013 Build System
:: https://gist.github.com/codito/e430d3b155b9af675ba9#file-runphonetests-bat
@ECHO OFF
:: Modify to match to your TFS Build environment
SET TEAMPROJECT="Demo"
SET TFS="https://mysampleapp.visualstudio.com/DefaultCollection/"
SET RUNNAME="PhoneTests-Build"
SET RUNSETTINGS="SamplePhoneTests.runsettings"
SET TESTPACKAGE="%TF_BUILD_BINARIESDIRECTORY%\CSJupiterTest\AppPackages\CSJupiterTest_1.0.0.0_x86_Debug_Test\CSJupiterTest_1.0.0.0_x86_Debug.appx"
SET VSTEST="C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
SET LOGGER=TfsPublisher;Collection="%TFS%";TeamProject="%TEAMPROJECT%";BuildName="%TF_BUILD_BUILDNUMBER%";Platform=x86;Flavor=Debug;RunTitle=%RUNNAME%
%VSTEST% %TESTPACKAGE% /logger:%LOGGER% /settings:%RUNSETTINGS%
:: Killing the Windows Phone Emulator to prepare for the next build
TASKKILL /F /FI "IMAGENAME EQ XDE*"
<!-- Sample runsettings. Please modify as appropriate -->
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<!-- Path relative to solution directory -->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<!-- [x86] | x64
- You can also change it from menu Test, Test Settings, Default Processor Architecture -->
<TargetPlatform>x86</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
</RunConfiguration>
<!-- Configurations for data collectors -->
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*CPPUnitTestFramework.*</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<!-- Adapter Specific sections -->
<!-- MSTest adapter -->
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
</MSTest>
<MSPhoneTest>
<TargetDevice>Emulator 8.1 WVGA 4 inch 512MB</TargetDevice>
</MSPhoneTest>
</RunSettings>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment