Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable MTP #37001

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions .pipelines/v2/templates/job-test-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ jobs:
sdk: true
version: '9.0'

- task: VisualStudioTestPlatformInstaller@1
displayName: Ensure VSTest Platform

- pwsh: |-
& '$(build.sourcesdirectory)\.pipelines\InstallWinAppDriver.ps1'
displayName: Download and install WinAppDriver
Expand All @@ -85,18 +82,7 @@ jobs:
inputs:
displaySettings: 'optimal'

- task: VSTest@3
displayName: Run UI Tests
inputs:
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
testSelector: 'testAssemblies'
searchFolder: '$(Pipeline.Workspace)\build-${{ parameters.platform }}-${{ parameters.configuration }}${{ parameters.inputArtifactStem }}'
vsTestVersion: 'toolsInstaller'
uiTests: true
rerunFailedTests: true
testAssemblyVer2: |
**\UITests-FancyZones.dll
**\UITests-FancyZonesEditor.dll
!**\obj\**
!**\ref\**
- script:
dotnet test $(Build.SourcesDirectory)\src\modules\fancyzones\UITests-FancyZones\UITests-FancyZones.csproj --no-build -c $(BuildConfiguration) -p:Platform=$(BuildPlatform)
dotnet test $(Build.SourcesDirectory)\src\modules\fancyzones\UITests-FancyZonesEditor\UITests-FancyZonesEditor.csproj --no-build -c $(BuildConfiguration) -p:Platform=$(BuildPlatform)
displayName: "Run UI Tests"
22 changes: 19 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
<NuGetAuditMode>direct</NuGetAuditMode>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> <!-- Don't add source revision hash to the product version of binaries. -->
<PlatformTarget>$(Platform)</PlatformTarget>

<!-- Enable Microsoft.Testing.Platform -->
<EnableMSTestRunner>true</EnableMSTestRunner>
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
<TestingPlatformDotNetTestSupport>true</TestingPlatformDotNetTestSupport>

<!-- No arm64 agents to run the tests. -->
<TestingPlatformDisableCustomTestTarget Condition="'$(Platform)' == 'ARM64'">true</TestingPlatformDisableCustomTestTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildProjectExtension)' == '.csproj'">
Expand Down Expand Up @@ -45,7 +53,15 @@
</PackageReference>
</ItemGroup>

<!-- Add ability to run tests via "msbuild /t:Test" -->
<!-- In CI, we build and test with `/t:Build;Test` -->
<!-- So, for non-test projects, we want the target to be there and it's basically doing nothing -->
<!-- For C# test projects, Microsoft.Testing.Platform should inject Test target here: -->
<!-- https://github.com/microsoft/testfx/blob/5ad21909704db501f58f27d4a7ec241edd761af5/src/Platform/Microsoft.Testing.Platform.MSBuild/buildMultiTargeting/Microsoft.Testing.Platform.MSBuild.targets#L270-L273 -->
<!-- For C++ test projects, the RunVSTest SDK will do its job -->
<Target Name="Test" />

<!-- Add ability to run tests via "msbuild /t:Test" using the RunVSTest SDK -->
<!-- This is only needed for C++, as we use Microsoft.Testing.Platform for C# -->
<!--
Workaround an MSBuild bug where Microsoft.Common.Test.targets is missing from the Arm64 installation.
See: https://github.com/dotnet/msbuild/pull/9984
Expand All @@ -55,11 +71,11 @@
Once the change referenced above is fixed, the ImportGroup below can be replaced with:
<Sdk Name="Microsoft.Build.RunVSTest" Version="1.0.319" />
-->
<ImportGroup Condition="'$(PROCESSOR_ARCHITECTURE)' != 'ARM64'">
<ImportGroup Condition="'$(PROCESSOR_ARCHITECTURE)' != 'ARM64' AND ('$(Language)' == 'C++' OR '$(MSBuildProjectExtension)' == '.vcxproj')">
<Import Project="Sdk.props" Sdk="Microsoft.Build.RunVSTest" Version="1.0.319" />
<Import Project="Sdk.targets" Sdk="Microsoft.Build.RunVSTest" Version="1.0.319" />
</ImportGroup>
<PropertyGroup>
<PropertyGroup Condition="'$(Language)' == 'C++' OR '$(MSBuildProjectExtension)' == '.vcxproj'">
<VSTestLogger>trx</VSTestLogger>
<!--
RunVSTest by default uses %VSINSTALLDIR%\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe,
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<PackageVersion Include="ModernWpfUI" Version="0.9.4" />
<!-- Moq to stay below v4.20 due to behavior change. need to be sure fixed -->
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="MSTest" Version="3.6.3" />
<PackageVersion Include="MSTest" Version="3.7.3" />
<PackageVersion Include="NLog" Version="5.0.4" />
<PackageVersion Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageVersion Include="NLog.Schema" Version="5.2.8" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<RootNamespace>Microsoft.FancyZones.UITests</RootNamespace>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<OutputType>Library</OutputType>
<!-- This is a UI test, so don't run as part of MSBuild -->
<RunVSTest>false</RunVSTest>
<OutputType>Exe</OutputType>

<!-- This is a UI test, so don't run as part of the Test target -->
<TestingPlatformDisableCustomTestTarget>true</TestingPlatformDisableCustomTestTarget>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ namespace UITests_FancyZonesEditor
public class RunFancyZonesEditorTest
{
private static FancyZonesEditorSession? _session;
private static TestContext? _context;
private readonly TestContext _context;

public RunFancyZonesEditorTest(TestContext context)
=> _context = context;

[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
_context = testContext;

// prepare files to launch Editor without errors
EditorParameters editorParameters = new EditorParameters();
EditorParameters.ParamsWrapper parameters = new EditorParameters.ParamsWrapper
Expand Down Expand Up @@ -133,19 +134,18 @@ public static void ClassInitialize(TestContext testContext)
public static void ClassCleanup()
{
FancyZonesEditorSession.Files.Restore();
_context = null;
}

[TestInitialize]
public void TestInitialize()
{
_session = new FancyZonesEditorSession(_context!);
_session = new FancyZonesEditorSession(_context);
}

[TestCleanup]
public void TestCleanup()
{
_session?.Close(_context!);
_session?.Close(_context);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<RootNamespace>Microsoft.FancyZonesEditor.UITests</RootNamespace>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<OutputType>Library</OutputType>
<OutputType>Exe</OutputType>

<!-- This is a UI test, so don't run as part of MSBuild -->
<RunVSTest>false</RunVSTest>
<!-- This is a UI test, so don't run as part of the Test target -->
<TestingPlatformDisableCustomTestTarget>true</TestingPlatformDisableCustomTestTarget>
</PropertyGroup>

<PropertyGroup>
Expand Down