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

Include Integration tests in code coverage #147

Merged
merged 23 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 7 additions & 8 deletions builds/azure-pipelines/template-steps-build-test-linux.yml
Expand Up @@ -6,7 +6,12 @@ parameters:

steps:
- task: UseDotNet@2
displayName: 'Install .NET Core SDK 3.1.x for Build'
displayName: 'Install .NET Core SDK 5.0.x for Running Tests'
inputs:
version: '5.0.x'

- task: UseDotNet@2
displayName: 'Install .NET Core 3.1 SDK for Azure Functions Build'
inputs:
version: '3.1.x'

Expand Down Expand Up @@ -131,13 +136,7 @@ steps:
inputs:
command: test
projects: '${{ parameters.solution }}'
arguments: '--configuration ${{ parameters.configuration }} ${{ parameters.testFilter }} /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.ArtifactStagingDirectory)\TestResults\coverage\ /p:Exclude="[*]Microsoft.Azure.WebJobs.Extensions.Sql.Samples.*"'

- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage Results'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.ArtifactStagingDirectory)/TestResults/coverage/coverage.cobertura.xml'
arguments: '--configuration ${{ parameters.configuration }} ${{ parameters.testFilter }} --collect "Code Coverage" -s $(Build.SourcesDirectory)/test/coverage.runsettings'

- script: |
docker stop sql1
Expand Down
8 changes: 1 addition & 7 deletions builds/azure-pipelines/template-steps-build-test.yml
Expand Up @@ -127,10 +127,4 @@ steps:
inputs:
command: test
projects: '${{ parameters.solution }}'
arguments: '--configuration ${{ parameters.configuration }} ${{ parameters.testFilter }} /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.ArtifactStagingDirectory)\TestResults\coverage\ /p:Exclude="[*]Microsoft.Azure.WebJobs.Extensions.Sql.Samples.*"'

- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage Results'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.ArtifactStagingDirectory)\TestResults\coverage\coverage.cobertura.xml'
arguments: '--configuration ${{ parameters.configuration }} ${{ parameters.testFilter }} --collect "Code Coverage" -s $(Build.SourcesDirectory)/test/coverage.runsettings'
2 changes: 1 addition & 1 deletion test/Integration/IntegrationTestBase.cs
Expand Up @@ -181,7 +181,7 @@ protected void StartFunctionHost(string functionName, bool useTestFolder = false
this.FunctionHost.BeginOutputReadLine();
this.FunctionHost.BeginErrorReadLine();

Thread.Sleep(5000); // This is just to give some time to func host to start, maybe there's a better way to do this (check if port's open?)
Thread.Sleep(10000); // This is just to give some time to func host to start, maybe there's a better way to do this (check if port's open?)
}

private string GetFunctionsCoreToolsPath()
Expand Down
4 changes: 1 addition & 3 deletions test/Microsoft.Azure.WebJobs.Extensions.Sql.Tests.csproj
Expand Up @@ -7,12 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Moq" Version="4.14.3" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
</ItemGroup>

Expand Down
19 changes: 19 additions & 0 deletions test/coverage.runsettings
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<SplitCoverage>True</SplitCoverage>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does SplitCoverage mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SplitCoverage is so that we can see the Code Coverage tab in ADO.
More details from this comment here: microsoft/vstest#981 (comment)

<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*\Microsoft.Azure.WebJobs.Extensions.Sql.dll$</ModulePath>
</Include>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>