Skip to content

Commit

Permalink
Fixed E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Haplois committed Nov 23, 2020
1 parent 9abcf05 commit e60d779
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 41 deletions.
2 changes: 1 addition & 1 deletion scripts/common.lib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function Locate-VsInstallPath($hasVsixExtension ="false"){
$requiredPackageIds = @()

$requiredPackageIds += "Microsoft.Component.MSBuild"
$requiredPackageIds += "Microsoft.Net.Component.4.6.TargetingPack"
$requiredPackageIds += "Microsoft.Net.Component.4.5.2.TargetingPack"
$requiredPackageIds += "Microsoft.VisualStudio.Windows.Build"

if($hasVsixExtension -eq 'true')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TestPlatform.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="11.0.0.0-12.0.0.0" newVersion="15.0.0.0" />
<assemblyIdentity name="Microsoft.VisualStudio.TestPlatform.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="11.0.0.0-12.0.0.0" newVersion="15.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
<assemblyIdentity name="System.ComponentModel.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MSTestAdapter.PlatformServices.Desktop.ComponentTests</RootNamespace>
<AssemblyName>PlatformServices.Desktop.ComponentTests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net451</TargetFramework>
<TargetFramework>net452</TargetFramework>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(TestFxRoot)artifacts\TestAssets\ComponentTests</OutputPath>
Expand Down
2 changes: 1 addition & 1 deletion test/E2ETests/Automation.CLI/Automation.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Automation.CLI</RootNamespace>
<AssemblyName>Automation.CLI</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand Down
25 changes: 17 additions & 8 deletions test/E2ETests/Smoke.E2E.Tests/DeploymentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace MSTestAdapter.Smoke.E2ETests
[TestClass]
public class DeploymentTests : CLITestBase
{
private const string TestAssembly = "DesktopDeployment\\DeploymentTestProject.dll";
private const string TestAssemblyDependency = "DesktopDeployment\\Never\\DeploymentTestProject.dll";
private const string TestAssemblyMSBuild = "DesktopDeployment\\PreserveNewest\\DeploymentTestProject.dll";
private const string TestAssemblyNetCore10 = "netcoreapp1.0\\DeploymentTestProjectNetCore.dll";
private const string TestAssemblyNetCore21 = "netcoreapp2.1\\DeploymentTestProjectNetCore.dll";
private const string RunSetting =
Expand All @@ -22,17 +23,17 @@ public class DeploymentTests : CLITestBase
[TestMethod]
public void ValidateTestSourceDependencyDeployment()
{
this.InvokeVsTestForExecution(new string[] { TestAssembly });
this.ValidatePassedTestsContain("DeploymentTestProject.UnitTest1.FailIfFilePresent", "DeploymentTestProject.UnitTest1.PassIfDeclaredFilesPresent");
this.ValidateFailedTestsContain("DeploymentTestProject.dll", true, "DeploymentTestProject.UnitTest1.PassIfFilePresent");
this.InvokeVsTestForExecution(new string[] { TestAssemblyDependency });
this.ValidatePassedTestsContain("DeploymentTestProject.DeploymentTestProject.FailIfFilePresent", "DeploymentTestProject.DeploymentTestProject.PassIfDeclaredFilesPresent");
this.ValidateFailedTestsContain(TestAssemblyMSBuild, true, "DeploymentTestProject.DeploymentTestProject.PassIfFilePresent");
}

[TestMethod]
public void ValidateTestSourceLocationDeployment()
{
this.InvokeVsTestForExecution(new string[] { TestAssembly }, RunSetting);
this.ValidatePassedTestsContain("DeploymentTestProject.UnitTest1.PassIfFilePresent", "DeploymentTestProject.UnitTest1.PassIfDeclaredFilesPresent");
this.ValidateFailedTestsContain("DeploymentTestProject.dll", true, "DeploymentTestProject.UnitTest1.FailIfFilePresent");
this.InvokeVsTestForExecution(new string[] { TestAssemblyMSBuild }, RunSetting);
this.ValidatePassedTestsContain("DeploymentTestProject.DeploymentTestProject.PassIfFilePresent", "DeploymentTestProject.DeploymentTestProject.PassIfDeclaredFilesPresent");
this.ValidateFailedTestsContain(TestAssemblyMSBuild, true, "DeploymentTestProject.DeploymentTestProject.FailIfFilePresent");
}

/*
Expand All @@ -50,9 +51,17 @@ public void ValidateTestSourceLocationDeploymentNetCore1_0()
[TestMethod]
public void ValidateTestSourceLocationDeploymentNetCore2_1()
{
// StackTrace isn't included in release builds with netcoreapp2.1.
const bool validateStackTrace =
#if DEBUG
true;
#else
false;
#endif

this.InvokeVsTestForExecution(new string[] { TestAssemblyNetCore21 }, null);
this.ValidatePassedTestsContain("DeploymentTestProjectNetCore.DeploymentTestProjectNetCore.FailIfFilePresent", "DeploymentTestProjectNetCore.DeploymentTestProjectNetCore.PassIfDeclaredFilesPresent");
this.ValidateFailedTestsContain("DeploymentTestProjectNetCore.dll", true, "DeploymentTestProjectNetCore.DeploymentTestProjectNetCore.PassIfFilePresent");
this.ValidateFailedTestsContain(TestAssemblyMSBuild, validateStackTrace, "DeploymentTestProjectNetCore.DeploymentTestProjectNetCore.PassIfFilePresent");
}
}
}
8 changes: 5 additions & 3 deletions test/E2ETests/Smoke.E2E.Tests/Smoke.E2E.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MSTestAdapter.Smoke.E2ETests</RootNamespace>
<AssemblyName>MSTestAdapter.Smoke.E2ETests</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TestProjectType>UnitTest</TestProjectType>
Expand All @@ -22,17 +22,19 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition=" '$(Configuration)' == 'Debug' ">DEBUG;TRACE</DefineConstants>
<DefineConstants Condition=" '$(Configuration)' == 'Release' ">TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.IO;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DeploymentTestProject
{
[DeploymentItem("DeploymentFile.xml")]

[DeploymentItem(@"..\..\..\..\test\E2ETests\TestAssets\DeploymentTestProject\DeploymentFile.xml")]
[TestClass]
public class UnitTest1
public class DeploymentTestProject
{
[TestMethod]
public void PassIfFilePresent()
Expand All @@ -20,7 +20,7 @@ public void FailIfFilePresent()
Assert.IsFalse(File.Exists("EmptyDataFile.xml"));
}

[DeploymentItem("TestCaseDeploymentFile.xml")]
[DeploymentItem(@"..\..\..\..\test\E2ETests\TestAssets\DeploymentTestProject\TestCaseDeploymentFile.xml")]
[TestMethod]
public void PassIfDeclaredFilesPresent()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TestFxRoot Condition="$(TestFxRoot) == ''">..\..\..\..\</TestFxRoot>
<DependencyCopyBehavior Condition="$(DependencyCopyBehavior) == ''">Never</DependencyCopyBehavior>
</PropertyGroup>

<Import Project="$(TestFxRoot)scripts\build\TestFx.Versions.targets" />

<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<IsPackable>false</IsPackable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>$(TestFxRoot)artifacts\TestAssets\\DesktopDeployment\</OutputPath>

<OutputPath>$(TestFxRoot)artifacts\TestAssets\DesktopDeployment\$(DependencyCopyBehavior)\</OutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\src\TestFramework\Extension.Desktop\Extension.Desktop.csproj" />
<ProjectReference Include="..\..\..\..\src\TestFramework\MSTest.Core\MSTest.Core.csproj" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestPlatformVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(TestFxRoot)src\TestFramework\Extension.Desktop\Extension.Desktop.csproj" />
<ProjectReference Include="$(TestFxRoot)src\TestFramework\MSTest.Core\MSTest.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -23,13 +27,20 @@

<ItemGroup>
<None Update="DeploymentFile.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>$(DependencyCopyBehavior)</CopyToOutputDirectory>
</None>
<None Update="EmptyDataFile.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>$(DependencyCopyBehavior)</CopyToOutputDirectory>
</None>
<None Update="TestCaseDeploymentFile.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>$(DependencyCopyBehavior)</CopyToOutputDirectory>
</None>
</ItemGroup>

<Target Name="CleanWithPreserveNewest" AfterTargets="Clean" Condition="$(DependencyCopyBehavior) == 'Never'">
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Clean" Properties="DependencyCopyBehavior=PreserveNewest" />
</Target>
<Target Name="BuildWithPreserveNewest" AfterTargets="Rebuild;Build" Condition="$(DependencyCopyBehavior) == 'Never'">
<MSBuild Projects="$(MSBuildProjectFullPath)" Properties="DependencyCopyBehavior=PreserveNewest" />
</Target>
</Project>
15 changes: 9 additions & 6 deletions test/UnitTests/PlatformServices.Desktop.Unit.Tests/App.config
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TestPlatform.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="11.0.0.0-12.0.0.0" newVersion="15.0.0.0" />
<assemblyIdentity name="Microsoft.VisualStudio.TestPlatform.ObjectModel" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="11.0.0.0-12.0.0.0" newVersion="15.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
<assemblyIdentity name="System.ComponentModel.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MSTestAdapter.PlatformServices.Desktop.UnitTests</RootNamespace>
<AssemblyName>MSTestAdapter.PlatformServices.Desktop.UnitTests</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down

0 comments on commit e60d779

Please sign in to comment.