Skip to content

Commit

Permalink
MSTest.Sdk: add support for Aspire
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Apr 24, 2024
1 parent 13ee145 commit 0fbc56e
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 15 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<PropertyGroup Label="Product dependencies">
<AspireHostingTestingVersion>9.0.0-preview.3.24210.17</AspireHostingTestingVersion>
<!-- Test Platform, .NET Test SDK and Object Model -->
<MicrosoftNETTestSdkVersion>17.9.0</MicrosoftNETTestSdkVersion>
<!-- UWP and WinUI dependencies -->
Expand Down
2 changes: 1 addition & 1 deletion src/Package/MSTest.Sdk/MSTest.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</ItemGroup>
<Target Name="GenerateTemplates" AfterTargets="PrepareForBuild">
<PropertyGroup>
<_TemplateProperties>MSTestEngineVersion=$(MSTestEngineVersion);MSTestVersion=$(Version);MicrosoftTestingPlatformVersion=$(MicrosoftTestingPlatformVersion);MicrosoftNETTestSdkVersion=$(MicrosoftNETTestSdkVersion);MicrosoftTestingExtensionsCodeCoverageVersion=$(MicrosoftTestingExtensionsCodeCoverageVersion);MicrosoftPlaywrightVersion=$(MicrosoftPlaywrightVersion)</_TemplateProperties>
<_TemplateProperties>MSTestEngineVersion=$(MSTestEngineVersion);MSTestVersion=$(Version);MicrosoftTestingPlatformVersion=$(MicrosoftTestingPlatformVersion);MicrosoftNETTestSdkVersion=$(MicrosoftNETTestSdkVersion);MicrosoftTestingExtensionsCodeCoverageVersion=$(MicrosoftTestingExtensionsCodeCoverageVersion);MicrosoftPlaywrightVersion=$(MicrosoftPlaywrightVersion);AspireHostingTestingVersion=$(AspireHostingTestingVersion)</_TemplateProperties>
</PropertyGroup>

<!--
Expand Down
21 changes: 21 additions & 0 deletions src/Package/MSTest.Sdk/Sdk/Features/Aspire.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<PackageReference Include="Aspire.Hosting.Testing" Version="$(AspireHostingTestingVersion)" IsImplicitlyDefined="True" Sdk="MSTest" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" IsImplicitlyDefined="True" Sdk="MSTest" />
<PackageReference Include="MSTest.Analyzers" Version="$(MSTestVersion)" IsImplicitlyDefined="True" Condition=" '$(EnableMSTestAnalyzers)' != 'false' " Sdk="MSTest" />
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestVersion)" IsImplicitlyDefined="True" Sdk="MSTest" />
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" IsImplicitlyDefined="True" Sdk="MSTest" />
</ItemGroup>

<!--
Implicit imports
Ensure feature is available and user hasn't opted-out from it.
See https://github.com/dotnet/sdk/blob/f9fdf2c7d94bc86dc443e5a9ffecbd1962b1d85d/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.props#L26-L34
-->
<ItemGroup Condition=" '$(ImplicitUsings)' == 'true' OR '$(ImplicitUsings)' == 'enable' ">
<Using Include="Aspire.Hosting.Testing" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions src/Package/MSTest.Sdk/Sdk/Features/Playwright.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup>
<PackageReference Include="Microsoft.Playwright.MSTest" Version="$(MicrosoftPlaywrightVersion)" IsImplicitlyDefined="True" Sdk="MSTest" />
<PackageReference Include="MSTest.Analyzers" Version="$(MSTestVersion)" IsImplicitlyDefined="True" Condition=" '$(EnableMSTestAnalyzers)' != 'false' " Sdk="MSTest" />
</ItemGroup>

<!--
Implicit imports
Ensure feature is available and user hasn't opted-out from it.
See https://github.com/dotnet/sdk/blob/f9fdf2c7d94bc86dc443e5a9ffecbd1962b1d85d/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.props#L26-L34
-->
<ItemGroup Condition=" '$(ImplicitUsings)' == 'true' OR '$(ImplicitUsings)' == 'enable' ">
<Using Include="Microsoft.Playwright.MSTest" />
</ItemGroup>

</Project>
8 changes: 3 additions & 5 deletions src/Package/MSTest.Sdk/Sdk/Runner/ClassicEngine.targets
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
<PackageReference Include="MSTest.Analyzers" Version="$(MSTestVersion)" IsImplicitlyDefined="True" Condition=" '$(EnableMSTestAnalyzers)' != 'false' " Sdk="MSTest" />
</ItemGroup>

<ItemGroup Condition=" '$(EnablePlaywright)' == 'true' ">
<PackageReference Include="Microsoft.Playwright.MSTest" Version="$(MicrosoftPlaywrightVersion)" IsImplicitlyDefined="True" Sdk="MSTest" />
<PackageReference Include="MSTest.Analyzers" Version="$(MSTestVersion)" IsImplicitlyDefined="True" Condition=" '$(EnableMSTestAnalyzers)' != 'false' " Sdk="MSTest" />
</ItemGroup>

<!-- Extensions -->
<ItemGroup>
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="$(MicrosoftTestingExtensionsTrxReportVersion)" IsImplicitlyDefined="True" Condition=" '$(EnableMicrosoftTestingExtensionsTrxReport)' == 'true' " Sdk="MSTest" />
Expand All @@ -49,4 +44,7 @@
<PackageReference Include="Microsoft.Testing.Extensions.Retry" Version="$(MicrosoftTestingExtensionsRetryVersion)" IsImplicitlyDefined="True" Condition=" '$(EnableMicrosoftTestingExtensionsRetry)' == 'true' " Sdk="MSTest" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)../Features/Aspire.targets" Condition=" '$(EnableAspire)' == 'true' " />
<Import Project="$(MSBuildThisFileDirectory)../Features/Playwright.targets" Condition=" '$(EnablePlaywright)' == 'true' " />

</Project>
1 change: 0 additions & 1 deletion src/Package/MSTest.Sdk/Sdk/Runner/Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
-->
<ItemGroup Condition="'$(ImplicitUsings)' == 'true' Or '$(ImplicitUsings)' == 'enable'">
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
<Using Include="Microsoft.Playwright.MSTest" Condition=" '$(EnablePlaywright)' == 'true' " />
</ItemGroup>

</Project>
6 changes: 5 additions & 1 deletion src/Package/MSTest.Sdk/Sdk/Runner/NativeAOT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<Import Project="$(MSBuildThisFileDirectory)Common.targets"/>

<Target Name="_MSTestSDKValidatePlaywright" BeforeTargets="Build">
<Error Condition=" '$(EnablePlaywright)' == 'true' " Text="Playwright currently doesn't support NativeAOT mode." />
<Error Condition=" '$(EnablePlaywright)' == 'true' " Text="Playwright MSTest currently doesn't support NativeAOT mode." />
</Target>

<Target Name="_MSTestSDKValidateAspire" BeforeTargets="Build">
<Error Condition=" '$(EnableAspire)' == 'true' " Text="Aspire MSTest currently doesn't support NativeAOT mode." />
</Target>

<!-- Core -->
Expand Down
3 changes: 3 additions & 0 deletions src/Package/MSTest.Sdk/Sdk/Sdk.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<EnableAspire Condition=" '$(EnableAspire)' == '' ">false</EnableAspire>
<EnablePlaywright Condition=" '$(EnablePlaywright)' == '' ">false</EnablePlaywright>
<UseVSTest Condition=" '$(UseVSTest)' == '' " >false</UseVSTest>

<AspireHostingTestingVersion Condition=" '$(AspireHostingTestingVersion)' == '' ">${AspireHostingTestingVersion}</AspireHostingTestingVersion>
<MSTestVersion Condition=" '$(MSTestVersion)' == '' ">${MSTestVersion}</MSTestVersion>
<MSTestEngineVersion Condition=" '$(MSTestEngineVersion)' == '' ">${MSTestEngineVersion}</MSTestEngineVersion>
<MicrosoftNETTestSdkVersion Condition=" '$(MicrosoftNETTestSdkVersion)' == '' ">${MicrosoftNETTestSdkVersion}</MicrosoftNETTestSdkVersion>
Expand Down
11 changes: 4 additions & 7 deletions src/Package/MSTest.Sdk/Sdk/VSTest/VSTest.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,16 @@
<PackageReference Include="MSTest.Analyzers" Version="$(MSTestVersion)" IsImplicitlyDefined="True" Condition=" '$(EnableMSTestAnalyzers)' != 'false' " Sdk="MSTest" />
</ItemGroup>

<ItemGroup Condition=" '$(EnablePlaywright)' == 'true' ">
<PackageReference Include="Microsoft.Playwright.MSTest" Version="$(MicrosoftPlaywrightVersion)" IsImplicitlyDefined="True" Sdk="MSTest" />
<PackageReference Include="MSTest.Analyzers" Version="$(MSTestVersion)" IsImplicitlyDefined="True" Condition=" '$(EnableMSTestAnalyzers)' != 'false' " Sdk="MSTest" />
</ItemGroup>

<!--
Implicit imports
Ensure feature is available and user hasn't opted-out from it.
See https://github.com/dotnet/sdk/blob/f9fdf2c7d94bc86dc443e5a9ffecbd1962b1d85d/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.props#L26-L34
-->
<ItemGroup Condition="'$(ImplicitUsings)' == 'true' Or '$(ImplicitUsings)' == 'enable'">
<ItemGroup Condition=" '$(ImplicitUsings)' == 'true' Or '$(ImplicitUsings)' == 'enable' ">
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
<Using Include="Microsoft.Playwright.MSTest" Condition=" '$(EnablePlaywright)' == 'true' " />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)../Features/Aspire.targets" Condition=" '$(EnableAspire)' == 'true' " />
<Import Project="$(MSBuildThisFileDirectory)../Features/Playwright.targets" Condition=" '$(EnablePlaywright)' == 'true' " />

</Project>

0 comments on commit 0fbc56e

Please sign in to comment.