diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml
index d29a6192a..27bd0ec58 100644
--- a/.azure-pipelines/ci-build.yml
+++ b/.azure-pipelines/ci-build.yml
@@ -100,12 +100,24 @@ extends:
arguments: '--configuration $(BuildConfiguration) --no-incremental'
# Run the Unit test
- - task: DotNetCoreCLI@2
+ - pwsh: |
+ dotnet test "$(Build.SourcesDirectory)\Microsoft.OpenApi.slnx" `
+ --configuration $(BuildConfiguration) `
+ --no-build `
+ -- `
+ --report-xunit-trx `
+ --results-directory "$(Agent.TempDirectory)\TestResults" `
+ --minimum-expected-tests 1
displayName: 'test'
+
+ - task: PublishTestResults@2
+ displayName: 'Publish test results'
+ condition: succeededOrFailed()
inputs:
- command: test
- projects: '$(Build.SourcesDirectory)\Microsoft.OpenApi.slnx'
- arguments: '--configuration $(BuildConfiguration) --no-build'
+ testResultsFormat: VSTest
+ testResultsFiles: '$(Agent.TempDirectory)\TestResults\*.trx'
+ failTaskOnMissingResultsFile: true
+ failTaskOnFailedTests: true
- task: EsrpCodeSigning@6
displayName: 'ESRP CodeSigning binaries'
diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml
index 13136e298..08e79d22a 100644
--- a/.github/workflows/ci-cd.yml
+++ b/.github/workflows/ci-cd.yml
@@ -45,7 +45,7 @@ jobs:
id: run_unit_tests
shell: pwsh
run: |
- dotnet test Microsoft.OpenApi.slnx -c Release --no-build -v n --collect:"XPlat Code Coverage"
+ dotnet test --solution Microsoft.OpenApi.slnx -c Release -v n --coverlet --coverlet-output-format cobertura
- name: Install report generator
shell: pwsh
@@ -55,7 +55,7 @@ jobs:
- name: Generate coverage report
shell: pwsh
run: |
- reportgenerator -reports:**/coverage.cobertura.xml -targetdir:./reports/coverage -reporttypes:"Html;MarkdownSummaryGithub;Cobertura"
+ reportgenerator -reports:**/coverage.cobertura*.xml -targetdir:./reports/coverage -reporttypes:"Html;MarkdownSummaryGithub;Cobertura"
- name: Add coverage to job summary
shell: bash
diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml
index d0ec5d462..2da4e7d46 100644
--- a/.github/workflows/sonarcloud.yml
+++ b/.github/workflows/sonarcloud.yml
@@ -61,12 +61,10 @@ jobs:
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
- CollectCoverage: true
- CoverletOutputFormat: 'opencover' # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682
shell: pwsh
run: |
- dotnet tool run dotnet-sonarscanner begin /k:"microsoft_OpenAPI.NET" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="test/**/coverage.opencover.xml"
+ dotnet tool run dotnet-sonarscanner begin /k:"microsoft_OpenAPI.NET" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover*.xml"
dotnet workload restore
dotnet build
- dotnet test Microsoft.OpenApi.slnx --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
+ dotnet test --solution Microsoft.OpenApi.slnx --verbosity normal --coverlet --coverlet-output-format opencover
dotnet tool run dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
\ No newline at end of file
diff --git a/global.json b/global.json
index 151193853..2f38dd557 100644
--- a/global.json
+++ b/global.json
@@ -1,5 +1,8 @@
{
"sdk": {
"version": "10.0.400"
+ },
+ "test": {
+ "runner": "Microsoft.Testing.Platform"
}
}
\ No newline at end of file
diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
index 95b457369..57543e05e 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
@@ -10,15 +10,14 @@
CA2007
true
..\..\src\Microsoft.OpenApi.snk
+ true
-
+
-
-
-
+
diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
index 7e6e44e78..dcbb3cebd 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
+++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
@@ -4,6 +4,7 @@
false
true
..\..\src\Microsoft.OpenApi.snk
+ true
@@ -15,12 +16,10 @@
-
-
+
-
-
+
diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
index 38941aae6..a2b406061 100644
--- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
@@ -5,17 +5,16 @@
true
Library
..\..\src\Microsoft.OpenApi.snk
+ true
-
-
+
-
-
+