Skip to content

Commit

Permalink
Include Integration tests in code coverage (#147)
Browse files Browse the repository at this point in the history
* use "Code Coverage"

* "Code Coverage" for pr pipeline

* update test sdk and remove coverlet

* wait 30s for func host to start

* increase wait time for queue trigger test

* decrease queue trigger wait time

* temp disable queue test

* use .net core 3.1.0

* change task order

* skip integration tests temporarily

* update to .net 5

* use .net 3.1 for azure functions

* add settings file

* update pr pipeline

* fix runsettings file

* edit runsettings file

* add code coverage package

* add split coverage setting

* reenable queue test

* decrease func host wait time

* add cobertura format + pr comment

* publish code coverage results

* revert back to split coverage
  • Loading branch information
lucyzhang929 committed Nov 5, 2021
1 parent bb550e8 commit 97d0a10
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
15 changes: 7 additions & 8 deletions builds/azure-pipelines/template-steps-build-test-linux.yml
Original file line number Diff line number Diff line change
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 @@ -121,13 +126,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
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>.*\Microsoft.Azure.WebJobs.Extensions.Sql.dll$</ModulePath>
</Include>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>

0 comments on commit 97d0a10

Please sign in to comment.