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

Update MSTest to metapackage and MTP #881

Merged
merged 23 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 22 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
17 changes: 15 additions & 2 deletions pipelines/build-test-tool-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ steps:
arguments: '-c $(BuildConfiguration)'

- task: DotNetCoreCLI@2
displayName: Run tests
displayName: Run unit tests (with coverage on Windows)
condition: eq(variables['Agent.OS'], 'Windows_NT')
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved
inputs:
command: 'test'
command: 'test'
nobuild: true
configuration: '$(BuildConfiguration)'
arguments: '-- --report-trx --results-directory $(Agent.TempDirectory) --coverage --coverage-output $(Agent.TempDirectory)/coverage.cobertura.xml --coverage-output-format cobertura'

- task: DotNetCoreCLI@2
displayName: Run unit tests (without coverage on non-Windows)
condition: ne(variables['Agent.OS'], 'Windows_NT')
inputs:
command: 'test'
nobuild: true
configuration: '$(BuildConfiguration)'
arguments: '-- --report-trx --results-directory $(Agent.TempDirectory)'
17 changes: 9 additions & 8 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"/>
<PropertyGroup>
<EnableMSTestRunner>true</EnableMSTestRunner>
<TestingPlatformDotNetTestSupport>true</TestingPlatformDotNetTestSupport>
<TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
</PropertyGroup>

<PropertyGroup Label="Build">
<GenerateDocumentationFile>True</GenerateDocumentationFile> <!-- Required for IDE0005 rule -->
</PropertyGroup>

<ItemGroup Label="Package References">
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="MSTest.TestAdapter"/>
<PackageReference Include="MSTest.TestFramework"/>
<PackageReference Include="Moq"/>
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
<PackageReference Include="MSTest" />
<PackageReference Include="Moq" />
</ItemGroup>

</Project>
7 changes: 3 additions & 4 deletions test/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
</PackageVersion>
</ItemDefinitionGroup>
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.7.3" />
<PackageVersion Include="MSTest.TestFramework" Version="3.7.3" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.13.1" />
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="1.5.3" />
<PackageVersion Include="MSTest" Version="3.7.3" />
<PackageVersion Include="Moq" Version="4.20.72" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<SignAssembly>True</SignAssembly>
<RootNamespace>Microsoft.Sbom.Adapters.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<SignAssembly>True</SignAssembly>
<RootNamespace>Microsoft.Sbom.Api.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<SignAssembly>True</SignAssembly>
<RootNamespace>Microsoft.Sbom.DependencyInjection.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);NU1605</NoWarn>
<AssemblyName>Microsoft.Sbom.Parsers.Spdx22SbomParser.Tests</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);NU1605</NoWarn>
<AssemblyName>Microsoft.Sbom.Parsers.Spdx30SbomParser.Tests</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net8.0</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand All @@ -11,6 +12,10 @@
<SBOMCLIToolProjectDir>$(MSBuildThisFileDirectory)..\..\src\Microsoft.Sbom.Tool\</SBOMCLIToolProjectDir>
<SBOMGenerationTargetsPath>$(MSBuildThisFileDirectory)..\..\src\Microsoft.Sbom.Targets\Microsoft.Sbom.Targets.targets</SBOMGenerationTargetsPath>
<NoWarn>CA1515;NU1903</NoWarn>
<!-- See https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-exit-codes -->
<!-- When all tests are ignored (or no test is found at all), MTP will exit with exit code 8, indicating that no tests were run -->
<!-- Currently, all tests are ignored in project when not running on Windows, so we ignore the exit code 8 in this case -->
<TestingPlatformCommandLineArguments Condition="'$(OS)' != 'Windows_NT'">$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<SignAssembly>True</SignAssembly>
<RootNamespace>Microsoft.Sbom.Tools.Tests</RootNamespace>
Expand Down