Skip to content

Commit

Permalink
Fixed integrationtests
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKert committed Mar 8, 2019
1 parent 0b1f15d commit f227aa9
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 142 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion src/BuildVision/Core/ServiceProviderExports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ public ServiceProviderExports([Import(typeof(SVsServiceProvider))] IServiceProvi

[Export]
public IPackageSettingsProvider PackageSettingsProvider => (IPackageSettingsProvider) _serviceProvider.GetService(typeof(IPackageSettingsProvider));

}
}
1 change: 0 additions & 1 deletion src/BuildVision/Core/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace BuildVision.Core
{

public static class Services
{
static TResult GetGlobalService<T, TResult>(IServiceProvider provider = null) where T : class where TResult : class
Expand Down
6 changes: 3 additions & 3 deletions src/BuildVision/Tool/Building/BuildOutputLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ private void EventSource_ErrorRaised(object sender, BuildEventArgs e, ErrorLevel

// case ErrorLevel.Warning:
// errorItem.Init((BuildWarningEventArgs) e);
// throw new ArgumentOutOfRangeException("errorLevel");
//}
//errorItem.VerifyValues();
// break;

// case ErrorLevel.Error:
// errorItem.Init((BuildErrorEventArgs) e);
// break;

// default:
// throw new ArgumentOutOfRangeException("errorLevel");
//}
//errorItem.VerifyValues();
//buildedProject.ErrorsBox.Add(errorItem);
//OnErrorRaised(this, new BuildErrorRaisedEventArgs(errorLevel, buildedProject));
}
Expand Down
112 changes: 34 additions & 78 deletions test/BuildVision.IntegrationTests/BuildVision.IntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -1,82 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FBB4F3ED-B1B8-4401-8667-5180194BAA54}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BuildVision.IntegrationTests</RootNamespace>
<AssemblyName>BuildVision.IntegrationTests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
<TargetFramework>net472</TargetFramework>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VSSDK.TestHostFramework, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="PackageTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="vstesthost.exp.testsettings" />
<None Include="vstesthost.testsettings" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\BuildVision\BuildVision.csproj">
<Project>{9925a635-1827-4bb4-9c31-fe0fc87a6265}</Project>
<Name>BuildVision</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="EnvDTE">
<Version>8.0.2</Version>
</PackageReference>
<PackageReference Include="EnvDTE80">
<Version>8.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.SDK.EmbedInteropTypes">
<Version>15.0.27</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>1.4.0</Version>
</PackageReference>
<PackageReference Include="stdole">
<Version>7.0.3303</Version>
</PackageReference>

<ItemGroup>
<PackageReference Include="EnvDTE" Version="8.0.2" />
<PackageReference Include="EnvDTE80" Version="8.0.3" />
<PackageReference Include="Microsoft.VisualStudio.SDK.EmbedInteropTypes" Version="15.0.27" />
<PackageReference Include="Microsoft.VSSDK.UnitTestLibrary" Version="14.3.25407" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="stdole" Version="7.0.3303" />
<PackageReference Include="xunit.vsix" Version="0.4.0-alpha.17" />
<PackageReference Include="Microsoft.VisualStudio.Setup.Configuration.Interop" PrivateAssets="all" Version="1.16.30" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

<ItemGroup>
<ProjectReference Include="..\..\src\BuildVision.Common\BuildVision.Common.csproj" />
<ProjectReference Include="..\..\src\BuildVision.Contracts\BuildVision.Contracts.csproj" />
<ProjectReference Include="..\..\src\BuildVision.UI\BuildVision.UI.csproj" />
<ProjectReference Include="..\..\src\BuildVision\BuildVision.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
<HintPath>..\..\libs\2017\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudioTools.VSTestHost.15.0">
<HintPath>..\..\libs\2017\Microsoft.VisualStudioTools.VSTestHost.15.0.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VSSDK.TestHostFramework">
<HintPath>..\..\libs\2017\Microsoft.VSSDK.TestHostFramework.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
82 changes: 39 additions & 43 deletions test/BuildVision.IntegrationTests/PackageTests.cs
Original file line number Diff line number Diff line change
@@ -1,58 +1,54 @@
using System;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TestTools.UnitTesting;
//using Microsoft.VSSDK.Tools.VsIdeTesting;
using System.ComponentModel.Design;
using EnvDTE;
using Microsoft.VisualStudio;
using BuildVision.Core;
using Microsoft.VSSDK.Tools.VsIdeTesting;
using Microsoft.VisualStudio;
using Xunit;
using System.Linq;
using System.Diagnostics;
using EnvDTE;

[assembly: VsixRunner(TraceLevel = SourceLevels.All)]
namespace BuildVision.IntegrationTests
{
[TestClass]
public class PackageTests
{
//private static IVsShell ShellService => VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsShell)) as IVsShell;
//private static IVsUIShell UiShellService => VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;
private static IVsShell ShellService => GlobalServices.GetService<SVsShell>() as IVsShell;
private static IVsUIShell UiShellService => GlobalServices.GetService<SVsUIShell>() as IVsUIShell;
private static DTE DTE => GlobalServices.GetService<DTE>() as DTE;

[VsixFact(VisualStudioVersion.Current, RootSuffix = "Exp")]
public void PackageLoad_Should_Succeed()
{
IVsPackage package;
var packageGuid = PackageGuids.GuidBuildVisionPackage;
var packageLoaded = ShellService.LoadPackage(ref packageGuid, out package);

//[Ignore]
//[TestMethod]
//[HostType("VS IDE")]
//public void PackageLoad_Should_Succeed()
//{
// UIThreadInvoker.Invoke(new Action(() =>
// {
// var guid = PackageGuids.GuidBuildVisionPackage;
// Assert.IsTrue(0 == ShellService.LoadPackage(ref guid, out var package));
// Assert.IsNotNull(package, "Package failed to load");
// }));
//}
Assert.Equal(0, packageLoaded);
Assert.NotNull(package);
}

//[Ignore]
//[TestMethod]
//[HostType("VS IDE")]
//public void ClickOnBuildVisionMenuItem_Should_ShowBuildVision()
//{
// UIThreadInvoker.Invoke(new Action(() =>
// {
// var toolwndCommandId = new CommandID(PackageGuids.GuidBuildVisionCmdSet, (int) PackageIds.CmdIdBuildVisionToolWindow);
// ExecuteCommand(toolwndCommandId);
// Assert.IsTrue(CanFindToolwindow(PackageGuids.GuidBuildVisionToolWindow));
// }));
//}
[VsixFact(VisualStudioVersion.Current, RootSuffix = "Exp")]
public void ClickOnBuildVisionMenuItem_Should_ShowBuildVision()
{
var toolwndCommandId = new CommandID(PackageGuids.GuidBuildVisionCmdSet, (int) PackageIds.CmdIdBuildVisionToolWindow);
ExecuteCommand(toolwndCommandId);
Assert.True(CanFindToolwindow(PackageGuids.GuidBuildVisionToolWindow));
}

//public static void ExecuteCommand(CommandID cmd)
//{
// object customin = null;
// object customout = null;
// VsIdeTestHostContext.Dte.Commands.Raise(cmd.Guid.ToString("B").ToUpper(), cmd.ID, ref customin, ref customout);
//}
private static void ExecuteCommand(CommandID cmd)
{
object customin = null;
object customout = null;
DTE.Commands.Raise(cmd.Guid.ToString("B").ToUpper(), cmd.ID, ref customin, ref customout);
}

//public static bool CanFindToolwindow(Guid persistenceGuid)
//{
// //var hr = UiShellService.FindToolWindow((uint) __VSFINDTOOLWIN.FTW_fFindFirst, ref persistenceGuid, out var windowFrame);
// //Assert.IsTrue(hr == VSConstants.S_OK);
// //return (windowFrame != null);
//}
private static bool CanFindToolwindow(Guid persistenceGuid)
{
var hr = UiShellService.FindToolWindow((uint) __VSFINDTOOLWIN.FTW_fFindFirst, ref persistenceGuid, out var windowFrame);
Assert.True(hr == VSConstants.S_OK);
return (windowFrame != null);
}
}
}
16 changes: 0 additions & 16 deletions test/BuildVision.IntegrationTests/Properties/AssemblyInfo.cs

This file was deleted.

1 change: 1 addition & 0 deletions tools/PrepareMachine.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.\VSTestHost.VS2017\InstallInVS2017.ps1 -vs "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise"
75 changes: 75 additions & 0 deletions tools/VSTestHost.VS2017/InstallInVS2017.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
param($vs)

$source = $MyInvocation.MyCommand.Definition | Split-Path -Parent

if (-not $vs) {
$vs = [Environment]::GetEnvironmentVariable("VisualStudio_15.0")
}
if (-not $vs) {
throw "-vs option must be specified"
}
if (-not (Test-Path $vs)) {
throw "specified path -vs $vs does not exist"
}
if (-not (Test-Path "$vs\Common7\IDE\devenv.exe")) {
throw "specified path -vs $vs does not contain a Visual Studio installation"
}

if (-not (Test-Path "$source\Microsoft.VisualStudioTools.VSTestHost.15.0.dll") -or
-not (Test-Path "$source\Microsoft.VisualStudioTools.VSTestHost.15.0.pkgdef")) {
throw "expected VSTestHost files in $source"
}

"Installing VSTestHost from $source"
copy "$source\Microsoft.VisualStudioTools.VSTestHost.15.0.dll" "$vs\Common7\IDE\CommonExtensions\Platform" -Force
copy "$source\Microsoft.VisualStudioTools.VSTestHost.15.0.pkgdef" "$vs\Common7\IDE\CommonExtensions\Platform" -Force

"Updating *.exe.config files"
gci @(
"$vs\Common7\IDE\MSTest.exe.config",
"$vs\Common7\IDE\QTAgent*.exe.config",
"$vs\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.*.exe.config"
) | ?{ Test-Path $_ } | %{
$conf = [xml](gc $_);
if (-not $conf.configuration.runtime.assemblyBinding.probing.privatePath.Contains("CommonExtensions\Microsoft\Editor")) {
$conf.configuration.runtime.assemblyBinding.probing.privatePath += ";CommonExtensions\Platform;CommonExtensions\Microsoft\Editor";

$n = $conf.configuration.runtime.assemblyBinding.AppendChild($conf.ImportNode(([xml]'<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="4.5.0.0-8.0.0.0" newVersion="8.0.0.0"/>
<codeBase version="8.0.0.0" href="PrivateAssemblies\Newtonsoft.Json.dll"/>
</dependentAssembly>').dependentAssembly, $true));

$conf.Save("$_");
" - $($_.Name)"
}
}

"Executing devenv /setup"
Start-Process -Wait -NoNewWindow "$vs\Common7\IDE\devenv.exe" "/setup"

"Generating testsettings files"
$ts = [xml](gc "$source\vs2017.testsettings.template")
foreach ($n in $ts.TestSettings.Execution.TestTypeSpecific.UnitTestRunConfig.AssemblyResolution.RuntimeResolution.Directory) {
$n.path = $n.path -replace '\$VSPath', "$vs";
$n.path = $n.path -replace '\$VSVersion', "15.0";
}
foreach ($n in $ts.TestSettings.Execution.TestTypeSpecific.UnitTestRunConfig.AssemblyResolution.DiscoveryResolution.Directory) {
$n.path = $n.path -replace '\$VSPath', "$vs";
$n.path = $n.path -replace '\$VSVersion', "15.0";
}
foreach ($n in $ts.TestSettings.Properties.Property) {
$n.value = $n.value -replace '\$VSPath', "$vs";
$n.value = $n.value -replace '\$VSVersion', "15.0";
}
$ts.Save("$vs\vstesthost.testsettings")
" - $vs\vstesthost.testsettings"

foreach ($n in $ts.TestSettings.Properties.Property) {
if ($n.name -eq "VSHive") {
$n.value = "Exp";
}
}
$ts.Save("$vs\vstesthost.exp.testsettings")
" - $vs\vstesthost.exp.testsettings"
""
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit f227aa9

Please sign in to comment.