I'm trying to setup CI server (TeamCity 7) and run daily build and smoke test on it for Windows store app. The smoke test should just launch the app, wait for 5 seconds and exit.
I created MSBuild script that compiles the code (after watching Pluralsight course on continuous integration). In my solution first project is Blank Windows store app, and second is Tests (Unit Test Library (Windows Store apps) - as described at http://msdn.microsoft.com/en-us/library/vstudio/hh440545.aspx).
But I can't find: A) How to launch the blank app from test method? B) How to run the test locally from msbuild script and on TeamCity server.
Using VS 2012 Premium on Windows 8 desktop.
Here is current script:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"
DefaultTargets="Compile" >
<UsingTask TaskName="MSBuild.ExtensionPack.Framework.AsyncExec"
AssemblyFile=".\Thirdparty\Tools\MSBuildAsyncExec\MSBuild.ExtensionPack.dll"/>
<UsingTask TaskName="RunAllTestsInSolution"
AssemblyFile=".\Thirdparty\Tools\MSBuildCustomTasks\RunAllTestsInSolution.dll"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
</PropertyGroup>
<ItemGroup>
<BuildArtifacts Include=".\buildartifacts\"/>
<SolutionFile Include=".\Decide Now.sln"/>
</ItemGroup>
<ItemGroup>
<!-- <MSTest Include=".\Thirdparty\Tools\MSTestFramework\Microsoft.VisualStudio.TestPlatform.UnitTestFramework.dll"/>-->
<TestAssembly Include=".\buildartifacts\Tests\Tests.dll"/>
<TestResults Include=".\buildartifacts\TestResults.trx"/>
</ItemGroup>
<PropertyGroup >
<VisualStudioDir>C:\Program Files (x86)\Microsoft Visual Studio 11.0\</VisualStudioDir>
<MSTest>$(VisualStudioDir)Common7\IDE\MSTest.exe</MSTest>
</PropertyGroup>
<Target Name="Clean">
<RemoveDir Directories="@(BuildArtifacts)"/>
<!-- TODO: Clean bin, obj and AppPackage folders in Sources and Test-->
</Target>
<Target Name="Init" DependsOnTargets="Clean">
<MakeDir Directories="@(BuildArtifacts)"/>
</Target>
<Target Name="Compile" DependsOnTargets="Init">
<MSBuild Projects="@(SolutionFile)" Targets="Rebuild"
Properties="OutDir=%(BuildArtifacts.FullPath);Configuration=$(Configuration)"/>
</Target>
<Target Name="Test" DependsOnTargets="Compile">
<!-- IgnoreExitCode=”true” -->
<Exec Command='"$(MSTest)" /testcontainer:@(TestAssembly) /resultsfile:@(TestResults)'/>
<Message Text='##teamcity[importData type="mstest" path="@(TestResults)"]'/>
</Target>
</Project>
Here is the sample test
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
namespace Decide_Now{
[TestClass]
public class SmokeTest{
[TestMethod]
public void RunOnce(){
int x = 1;
int y = 2;
Assert.AreEqual( 3, x + y );
/*App.Start( null );
//var mainPage = new MainPage();
Task.Delay( 3000 ).Wait();
App.Current.Exit();*/
}
}
}
As you see in comments I tried several methods, but if says following:
Test:
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe"
/testcontainer:.\buildartifacts\Tests\Tests.dll /resultsfile:.\buildartifacts
\TestResults.trx
Microsoft (R) Test Execution Command Line Tool Version 11.0.50727.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading .\buildartifacts\Tests\Tests.dll...
Starting execution...
No tests to execute.
##teamcity[importData type="mstest" path=".\buildartifacts\TestResults.trx"]
SOS.