Cobertura de código nos testes de uma aplicação .NET
- CQRS Pattern
- Notification Pattern
- Testes unitários
- Testes de Integração
- Cobertura de Testes
- Testes de Carga
- Docker
- CI/CD com Github Actions
- Code Quality com Sonaqube
- CQRS Pattern
- Notification Pattern
- Cobertura de Testes com Coverlet
- Coverlet Documentação
- POSTMAN: Dynamic Variables
- Running collections on the command line with Newman
- Automatizando testes de APIs REST com Postman + Newman
- K6 Testes de Carga
Executando os testes unitários:
dotnet test ./tests/SampleApp.Tests --verbosity minimal --logger:"html;LogFileName=tests-results.html" --collect:"XPlat Code Coverage"
You will need .NET EF Tools to run this commands
# add migration
dotnet ef migrations add <MIGRATION_NAME> -p src/SampleApp.Infra/ -c SampleAppContext -s src/SampleApp.Api -o Contexts/Migrations
# remove migration
dotnet ef migrations remove -p src/SampleApp.Infra/ -c SampleAppContext -s src/SampleApp.Api
# update database
dotnet ef database update -p src/SampleApp.Infra -c SampleAppContext -s src/SampleApp.Api
# generate scripts for manual database update
dotnet ef migrations script -p src/SampleApp.Infra/ -c SampleAppContext -s src/SampleApp.Api -o ./scripts/migrations.sql
Instalando a ferramenta de geração de relatório globalmente:
dotnet tool install --global dotnet-reportgenerator-globaltool
Gerando o relatório:
cd ./tests/SampleApp.Tests/TestResults
cd $(ls -d */|head -n 1)
reportgenerator "-reports:coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:Html
Instalando a ferramenta newman para gerar os testes integrados:
npm install -g newman
Executando os testes integrados
newman run tests/SampleApp.Integration.Tests/integration-tests.json -e tests/SampleApp.Integration.Tests/environments/docker.environment.json --insecure
dotnet tool install --global dotnet-sonarscanner
dotnet tool install --global dotnet-coverage
dotnet sonarscanner begin -o:tfsantosbr -k:tfsantosbr_dotnet-sample-api -d:sonar.host.url=https://sonarcloud.io -d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build --no-incremental
dotnet-coverage collect 'dotnet test' -f xml -o 'coverage.xml'
dotnet sonarscanner end
Instalando a ferramenta de testes de Carga K6:
Executando os Testes de Carga:
k6 run -e HOSTNAME=https://localhost:5001 tests/SampleApp.Load.Tests/script.js