Test Data and User Management Application
The poject is utilising NSwag to auto-generate client code for the front-end.
The configuration for the front end TypeScript can be found in 'TestWeb/ClientApp/api-ts.nswag'
- Install the NSwag CLI (at least version 12)
- Install Dotnet SDK 2.2
- Ensure the MVC application is running. This can be managed by either:
dotnet run TestWeb/TestWeb.csproj
- or via an IDE
- open a terminal at the folder containing the nswag file 'TestWeb/ClientApp'
- execute
nswag run
The latest version of the client code can be found in 'src/app/services/clients/api-client.ts'
First ensure you are running a terminal in the TestWeb directory of this repository and then run the following commands.
dotnet test --no-build TestWeb.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="\"opencover,cobertura,json,lcov\"" /p:CoverletOutput=../Artifacts/Coverage/ /p:MergeWith='../Artifacts/Coverage/coverage.json' /p:Exclude="\"[TestWeb.ConfigureServicesExtensions,[TestWeb]TestWeb.Program,[TestWeb]TestWeb.Startup,[*]TestWeb.Common.*,[*]TestWeb.Extensions.*,[*]TestWeb.Pages.*,[*]TestWeb.Swagger.*,[*]TestWeb.Views.*,[*]TestWeb.UnitTests.*,[*]TestWeb.Services.*,[*]Testing.Common.*\""
Using Poweshell
dotnet test --% --no-build TestWeb.UnitTests/TestWeb.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=\"opencover,cobertura,json,lcov\" /p:CoverletOutput=../Artifacts/Coverage/ /p:MergeWith='../Artifacts/Coverage/coverage.json' /p:Exclude=\"[TestWeb.ConfigureServicesExtensions,[TestWeb]TestWeb.Program,[TestWeb]TestWeb.Startup,[*]TestWeb.Common.*,[*]TestWeb.Extensions.*,[*]TestWeb.Pages.*,[*]TestWeb.Swagger.*,[*]TestWeb.Views.*,[*]TestWeb.UnitTests.*,[*]TestWeb.Services.*,[*]Testing.Common.*\"
Under the unit test project directory
dotnet reportgenerator "-reports:../Artifacts/Coverage/coverage.opencover.xml" "-targetDir:../Artifacts/Coverage/Report" -reporttypes:HtmlInline_AzurePipelines
Verify the source code passes linting. To quickly fix linting issues, execute the following command from the 'ClientApp' directory in a terminal
ng lint TestWeb --fix
Verify the source code passes linting. To quickly identify linting issues, execute the following command from the 'ClientApp' directory in a terminal
npm install
npm run prettify
Use the command below to apply prettier after installation packages
npm run prettify-fix
Install the extension : Coverage Gutters Id: ryanluker.vscode-coverage-gutters
This extension will load covage files and display in real-time which lines are covered
Ensure you have a terminal with the current directory set to the same level as angular workspace.
npm run test
This will execute the angular tests files with the --code-coverage parameter. Once the coverage files have been produced, enable the watch command for Coverage Gutters.
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 tests
User Secrets:
- "VhServices:TestWebUrl": "https://testweb_ac/"
Update following configuration under TestWeb/appsettings.json
- "AzureAd:RedirectUri": "https://testweb_ac/home"
- "AzureAd:PostLogoutRedirectUri": "https://testweb_ac/logout"
- "ZapScan": true
Update following configuration under TestWeb.AcceptanceTests/appsettings.json
- "AzureAd:RedirectUri": "https://testweb_ac/home"
- "AzureAd:PostLogoutRedirectUri": "https://testweb_ac/logout"
- "ZapConfiguration:ZapScan": true
To run stryker mutation test, go to UnitTest folder under command prompt and run the following command
dotnet stryker
From the results look for line(s) of code highlighted with Survived\No Coverage and fix them.
If in case you have not installed stryker previously, please use one of the following commands
dotnet tool install -g dotnet-stryker
dotnet tool install dotnet-stryker
To update latest version of stryker please use the following command
dotnet tool update --global dotnet-stryker