我正在尝试设置 CI 服务器(TeamCity 7)并在其上运行 Windows 商店应用程序的每日构建和冒烟测试。冒烟测试应该只是启动应用程序,等待 5 秒然后退出。
我创建了编译代码的 MSBuild 脚本(在观看 Pluralsight 持续集成课程之后)。在我的解决方案中,第一个项目是空白 Windows 商店应用程序,第二个项目是测试(单元测试库(Windows 商店应用程序) - 如http://msdn.microsoft.com/en-us/library/vstudio/hh440545.aspx所述) .
但我找不到:A)如何从测试方法启动空白应用程序?B) 如何在本地从 msbuild 脚本和 TeamCity 服务器上运行测试。
在 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>
这是样本测试
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"]
求救。