Unit Testing Windows Store App - MSBuild, MSTest and TeamCity

I am trying to set up a CI server (TeamCity 7) and run a daily build and smoke test on it for a windows store app. smoke test should just start the application, wait 5 seconds and exit.

I created an MSBuild script that compiles the code (after watching Pluralsight's continuous integration course). In my solution, the first project is an empty Windows store app and the 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 run an empty program from a test method? B) How to run test locally from msbuild script and on TeamCity server.

Using VS 2012 Premium on Windows 8 Desktop.

Here's the 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 an example 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 can see in the comments, I tried several methods, but if the following is said:

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.

+2


source to share


1 answer


To run your appx, see the code @ http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/a4d2fca1-4034-4cc7-a86a-6242ce1a8b16 You should be aware that your application will become inactive for a few seconds after opening, since you are not interacting with it.



To run tests on Windows8 storage, use vstest.console.exe instead of mstest.exe instead. vstest.console.exe is a new test runner in VS2012.

+4


source







All Articles