A practical example around code coverage for integration tests.
This is an example about how to get code coverage from integration tests.
In this case more specific using a messaging environment.
Tech
- RabbitMQ
- .Net Core 3.1
- dotCover (To collect coverage) download here
Steps to reproduce:
- Change the file LocalExecute.ps1 to reflect your folder structure.
- provide a RabbitMQ running on LocalHost (or change the configuration on appsettings.json).
- Configure the dotCover as a alias on your machine or change the reference for dotCover inside the script to match your DotCover executable.
- Execute the LocalExecute.ps1
The expected result:
- A folder
coverage
with a filereport.html
should appear on the current folder.
Execution Plan
- dotnet restore .\EntryPointProcessorSolution.sln
- dotnet build .\EntryPoint.Processor\EntryPoint.Processor.csproj -c Debug
- dotnet build .\EntryPoint.Integration.Test\EntryPoint.Integration.Test.csproj
- dotCover start configuration
- dotCover start watch target application
- dotnet test .\EntryPoint.Integration.Test\ --no-build
- dotCover end the session and generate the report
Exemplo pratico a respeito de cobertura de código em testes integrados
Este é um exemplo sobre como coletar cobertura de código em testes integrados. Olhando para um ambiente mais específico de mensageria.
Tecnologias
- RabbitMQ
- .Net Core 3.1
- dotCover (Para coletar a cobertura) baixar aqui
Passos para reproduzir:
- Modifique o arquivo LocalExecute.ps1 para refletir a sua estrutura de pastas.
- Uma instancia rodando do RabbitMQ no localhost (ou modifique o arquivo appsettings.json para receber as configurações da conexão).
- Configure o DotCover como um alias no windows ou modifique o Script Configure para coincidir com o seu executável do DotCover.
- Execute o LocalExecute.ps1
O resultado esperado:
- Uma pasta
coverage
com o arquivoreport.html
deve aparecer na pasta corrente com o resultado.
Plano de execução
- dotnet restore .\EntryPointProcessorSolution.sln
- dotnet build .\EntryPoint.Processor\EntryPoint.Processor.csproj -c Debug
- dotnet build .\EntryPoint.Integration.Test\EntryPoint.Integration.Test.csproj
- dotCover inicia as configurações
- dotCover começa a observar a aplicação
- dotnet test .\EntryPoint.Integration.Test\ --no-build
- dotCover finaliza a sessão e gera o relatório