我正在尝试安装CI服务器(TeamCity 7),并对Windows商店应用程序运行日常构build和冒烟testing。 烟雾testing应该启动应用程序,等待5秒钟,然后退出。
我创build了编译代码的MSBuild脚本(在观看关于持续集成的Pluralsight课程之后)。 在我的解决scheme中,第一个项目是空白Windows商店应用程序,第二个是testing(unit testing库(Windowsapp store应用程序) – 如http://msdn.microsoft.com/en-us/library/vstudio/hh440545.aspx所述 ) 。
但我找不到:A)如何从testing方法启动空白的应用程序? B)如何从msbuild脚本和TeamCity服务器本地运行testing。
在Windows 8桌面上使用VS 2012 Premium。
这里是当前脚本:
<?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>
这是样品testing
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();*/ } } }
正如你在评论中看到的,我尝试了几种方法,但如果说如下:
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。
要运行Windows8存储单元测试,请使用vstest.console.exe而不是mstest.exe。 vstest.console.exe是VS2012中新的单元测试执行程序。