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

test: Use dotnet test for running unit tests #19172

Draft
wants to merge 5 commits into
base: master
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
49 changes: 14 additions & 35 deletions build/ci/.azure-devops-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ jobs:
UWP:
UNO_UWP_BUILD: true
XAML_FLAVOR_BUILD: UWP
ADDITIONAL_FLAGS: ''

WinUI:
UNO_UWP_BUILD: false
XAML_FLAVOR_BUILD: WinUI
ADDITIONAL_FLAGS: ''

# Keep for future previews
# Preview:
# ADDITIONAL_FLAGS: '/p:LangVersion=preview /p:MicrosoftNetCompilerVersionOverride=3.8.0-3.final'

#CSharp9:
# ADDITIONAL_FLAGS: '/p:LangVersion=9.0'

variables:
CombinedConfiguration: Release|Any CPU
Expand Down Expand Up @@ -77,10 +68,9 @@ jobs:
cleanDestinationFolder: false
overwriteExistingFiles: true

- task: MSBuild@1
inputs:
solution: src/Uno.UI-UnitTests-only.slnf
msbuildArguments: /r /v:m /p:CheckExclusions=True /p:Configuration=Release /nodeReuse:true /detailedsummary /m $(ADDITIONAL_FLAGS) /bl:$(build.artifactstagingdirectory)\unit-tests-build-$(XAML_FLAVOR_BUILD).binlog
- pwsh: |
dotnet build src/Uno.UI-UnitTests-only.slnf -c Release -bl:$(build.artifactstagingdirectory)\unit-tests-build-$(XAML_FLAVOR_BUILD).binlog
displayName: Build unit tests solution filter

- task: PublishBuildArtifacts@1
condition: always()
Expand All @@ -90,27 +80,16 @@ jobs:
ArtifactName: NugetPackages-Artifacts
ArtifactType: Container

- task: VisualStudioTestPlatformInstaller@1
inputs:
versionSelector: specificVersion
testPlatformVersion: 17.6.0
- pwsh: |
dotnet test src/Uno.UI-UnitTests-only.slnf -c Release --no-build -- --report-trx --results-directory $(Build.SourcesDirectory)/artifacts/TestResults
displayName: Run unit tests

- task: VSTest@2
- task: PublishTestResults@2
displayName: Publish TRX Test Results
inputs:
testAssemblyVer2: |
**\*test*.dll
!**\obj\**
!**\*Wasm.Test*.dll
!**\*UITests.dll
!**\*.RuntimeTests.dll
!**\Uno.UI.Tests.ViewLibraryProps.dll
!**\Uno.UI.Tests.ViewLibrary.dll
!**\testhost*.*
!**\Microsoft*.dll

vsTestVersion: toolsInstaller
testRunTitle: $(Agent.JobName)
testSelector: testAssemblies
batchingBasedOnAgentsOption: customBatchSize
rerunFailedTests: 'true'
customBatchSizeValue: 200 # test count / 10 (https://developercommunity.visualstudio.com/content/problem/891803/vstestconsoleadapter-fails-with-outofmemory.html?childToView=896206#comment-896206)
testResultsFormat: 'VSTest'
testResultsFiles: '*.trx'
searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults'
testRunTitle: UnitTests-trx
continueOnError: true
condition: always()
3 changes: 2 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

<!-- Enable the MSTest runner, this is an opt-in feature when not using MSTest.Sdk -->
<EnableMSTestRunner>true</EnableMSTestRunner>
<TestingPlatformDotNetTestSupport>true</TestingPlatformDotNetTestSupport>

<!-- Ensures the .xr.xml files are generated in a proper layout folder -->
<GenerateLibraryLayout>true</GenerateLibraryLayout>
Expand Down Expand Up @@ -215,7 +216,7 @@

<PropertyGroup>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
<UnoDisableNetAnalyzers Condition="$(MSBuildProjectName.Contains('Test'))">true</UnoDisableNetAnalyzers>
<IsSampleProject>$(MSBuildProjectName.Contains('Sample'))</IsSampleProject>
<IsSampleProject Condition="'$(IsSampleProject)'=='false'">$(MSBuildProjectName.Contains('UnoIslands'))</IsSampleProject>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down
19 changes: 15 additions & 4 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@
</Target>

<PropertyGroup>
<!-- IMPORTANT!!! KEEP BOTH MSTest and MTP versions in sync -->
<!-- For a given MSTest version, go to https://www.nuget.org/packages/MSTest.TestAdapter/3.7.0#dependencies-body-tab -->
<!-- (replacing 3.7.0 in the url with the MSTest version in question) -->
<!-- And look for MTP version in there, and make sure MicrosoftTestingPlatformVersion is the same -->
<!-- Alternatively, migrate to MSTest.Sdk and let it handle the MTP versioning for you -->
<!-- In case of MSTest.Sdk, the TrxReport package will not be needed. It will be added automatically -->
<MSTestVersion>3.7.0</MSTestVersion>
<MicrosoftTestingPlatformVersion>1.5.0</MicrosoftTestingPlatformVersion>

<SkiaSharpVersion>2.88.7</SkiaSharpVersion>
<!-- TODO: Uncomment when we're net8.0+ to have SamplesApp serve as a good test for SkiaSharp 3 support -->
<!-- <SkiaSharpVersion Condition="'$(IsTestProject)' == 'true' or '$(IsSampleProject)' == 'true'">3.0.0-preview.3.1</SkiaSharpVersion> -->
Expand All @@ -76,10 +85,12 @@
<PackageReference Update="Uno.Core.Extensions.Compatibility" Version="4.0.1" />
<PackageReference Update="Uno.Diagnostics.Eventing" Version="2.0.1" />
<PackageReference Update="Uno.Wasm.Bootstrap" Version="9.0.8" />
<PackageReference Update="MSTest" Version="3.7.0" />
<PackageReference Update="MSTest.TestFramework" Version="3.6.3" />
<PackageReference Update="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Update="MSTest.Analyzers" Version="3.3.1" />
<PackageReference Update="MSTest" Version="$(MSTestVersion)" />
<PackageReference Update="MSTest.TestFramework" Version="$(MSTestVersion)" />
<PackageReference Update="MSTest.TestAdapter" Version="$(MSTestVersion)" />
<PackageReference Update="MSTest.Analyzers" Version="$(MSTestVersion)" />
<PackageReference Update="Microsoft.Testing.Extensions.TrxReport" Version="$(MicrosoftTestingPlatformVersion)" />

<PackageReference Update="Uno.MonoAnalyzers" Version="1.0.0" PrivateAssets="all" />
<PackageReference Update="Uno.Wasm.WebSockets" Version="1.1.0" />
<PackageReference Update="Microsoft.TypeScript.MSBuild" Version="4.3.5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

<ItemGroup>
<PackageReference Include="MSTest" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.12.0-3.final" />
<PackageReference Include="Microsoft.CodeAnalysis.Features" Version="4.12.0-3.final" />
Expand Down
1 change: 1 addition & 0 deletions src/Uno.Analyzers.Tests/Uno.Analyzers.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<ItemGroup>
<PackageReference Include="MSTest" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="$(CodeAnalysisVersionForAnalyzersTests)" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(CodeAnalysisVersionForAnalyzersTests)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(CodeAnalysisVersionForAnalyzersTests)" />
Expand Down
1 change: 1 addition & 0 deletions src/Uno.UI.Tests/Uno.UI.Unit.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="MSTest" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Moq" Version="4.17.2" />
<PackageReference Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.0-dev.7" PrivateAssets="all" />
Expand Down
Loading