dotnet sonarscanner begin /k:"vh-video-api" /d:sonar.cs.opencover.reportsPaths="VideoAPI/Artifacts/Coverage/coverage.opencover.xml" /d:sonar.coverage.exclusions="VideoApi/Program.cs,VideoApi/Startup.cs,VideoApi/Extensions/**,VideoApi/Swagger/**,**/VideoApi/ConfigureServicesExtensions.cs,**/Testing.Common/**,**/Testing.Common/Helper/,Helper/Builders/Api/,Helper/Builders/Domain/,VideoApi.Common/**,VideoApi.DAL/Mappings/**,VideoApi.DAL/SeedData/**,VideoApi.DAL/VideoApiDbContext.cs,VideoApi.DAL/**/DesignTimeHearingsContextFactory.cs,VideoApi.DAL/Migrations/**,VideoApi.Domain/Ddd/**,VideoApi.Domain/Validations/**" /d:sonar.cpd.exclusions="VideoApi.DAL/Migrations/**" /d:sonar.verbose=true
dotnet build VideoAPI/VideoApi.sln
dotnet sonarscanner end
First ensure you are running a terminal in the VideoAPI directory of this repository and then run the following commands.
dotnet test --no-build VideoApi.UnitTests/VideoApi.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="\"opencover,cobertura,json,lcov\"" /p:CoverletOutput=../Artifacts/Coverage/ /p:MergeWith='../Artifacts/Coverage/coverage.json' /p:Exclude="\"[*]VideoApi.Extensions.*,[VideoApi]VideoApi.ConfigureServicesExtensions,[VideoApi]VideoApi.Startup,[VideoApi]VideoApi.Program,[*]VideoApi.Swagger.*,[VideoApi.*Tests?]*,[*]VideoApi.DAL.SeedData.*,[*]VideoApi.DAL.Migrations.*,[*]VideoApi.DAL.Mappings.*,[*]VideoApi.Domain.Ddd.*,[*]VideoApi.Domain.Validations.*,[VideoApi.DAL]VideoApi.DAL.VideoApiDbContext,[VideoApi.DAL]VideoApi.DAL.DesignTimeHearingsContextFactory,[*]VideoApi.Common.*,[*]Testing.Common.*,[*]VideoApi.Services.*\""
dotnet test --no-build VideoApi.IntegrationTests/VideoApi.IntegrationTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="\"opencover,cobertura,json,lcov\"" /p:CoverletOutput=../Artifacts/Coverage/ /p:MergeWith='../Artifacts/Coverage/coverage.json' /p:Exclude="\"[*]VideoApi.Extensions.*,[VideoApi]VideoApi.ConfigureServicesExtensions,[VideoApi]VideoApi.Startup,[VideoApi]VideoApi.Program,[*]VideoApi.Swagger.*,[VideoApi.*Tests?]*,[*]VideoApi.DAL.SeedData.*,[*]VideoApi.DAL.Migrations.*,[*]VideoApi.DAL.Mappings.*,[*]VideoApi.Domain.Ddd.*,[*]VideoApi.Domain.Validations.*,[VideoApi.DAL]VideoApi.DAL.VideoApiDbContext,[VideoApi.DAL]VideoApi.DAL.DesignTimeHearingsContextFactory,[*]VideoApi.Common.*,[*]Testing.Common.*,[*]VideoApi.Services.*\""
Under the unit test project directory
dotnet reportgenerator "-reports:./Coverage/coverage.opencover.xml" "-targetDir:./Artifacts/Coverage/Report" -reporttypes:Html -sourcedirs:./VideoApi
The branch name should start with: feature/VIH-XXXX-branchName (X - is digit). If git version is less than 2.9 the pre-commit file from the .githooks folder need copy to local .git/hooks folder. To change git hooks directory to directory under source control run (works only for git version 2.9 or greater) : $ git config core.hooksPath .githooks
The commit message will be validated by prepare-commit-msg hook. The commit message format should start with : 'feature/VIH-XXXX : ' folowing by 8 or more characters description of commit, otherwise the warning message will be presented.
To run Zap scan locally update the following settings and run acceptance\integration tests
User Secrets:
- "Services:VideoApiUrl": "https://VideoApi_AC/"
Update following configuration under appsettings.json under VideoApi.AcceptanceTests or VideoApi.IntegrationTests
- "Services:VideoApiUrl": "https://VideoApi_AC/"
- "ZapConfiguration:ZapScan": true
- "ConnectionStrings:VhVideoApi": "Server=localhost,1433;Database=VhVideoApi;User=sa;Password=VeryStrongPassword!;" (IntegrationTest alone)
Note: Ensure you have Docker desktop engine installed and setup
Open a terminal at the root level of the repository and run the following command
docker-compose -f "docker-compose.tests.yml" up --build --abort-on-container-exit
You may need to create a
.env
file to store the environment variables
Visit the VH-Setup repository for Instructions to run as a container locally..