-
Notifications
You must be signed in to change notification settings - Fork 0
Tests
KlausEnevoldsen-Abtion edited this page Sep 26, 2023
·
2 revisions
- Api.Standalone.Tests: testing the minimal API of the Api.Standalone project with XUnit.
- Api.WithReact.Tests: testing the API in the controller actions of the Api.WithReact project with XUnit.
- DomainModel.Tests: testing the Domain Model project with XUnit.
- EndToEnd.Tests: testing the Api.WithReact project with Playwright
To install Chromium for Playwright, start PowerShell as Administrator. (by right-clicking the PowerShell shortcut in the Start Menu and selecting "Run as Administrator".)
From the root folder of the Muffi.NET project, run the following PowerShell commands:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSignedcd tests\EndToEnd.Tests.\bin\Debug\net7.0\playwright.ps1 install chromium
Backend
dotnet testFrontend
yarn testFor these tests we use the Gherkin syntax. Examples:
- Given_SystemIsRunning_When_TheLandingPageIsCall_Then_ThePageIsShown
- Given_UserExists_When_LoggingIn_Then_UserIsLoggedInAndRedirected
- Given_UserDoesNotExist_When_LoggingIn_Then_UserIsNotLoggedIn
- Given_UserExistsAndIsLoggedIn_When_LoggingOut_Then_UserIsLoggedOutAndRedirected
For these tests we use a shorter naming convention: MethodName_ExpectedBehavior_StateUnderTest. Examples:
- LoadAll_ReturnTypeIsCorrect_WhenRequestIsValid
- GetContactFormInformationIsCalled_ReturnsLoadContactFormResponse_WhenRequestIsValid
- LoadJiraIssueDetails_ReturnsAnJiraIssueDetailsInstanceWithCorrectFields_WhenJiraIdentifierIsCorrect
Backend code coverage requires Coverlet & ReportGenerator:
dotnet tool install -g dotnet-reportgenerator-globaltooldotnet tool install -g coverlet.console
Backend report: (note slash/backslash use differs on different cmd shells)
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov ./tests/DomainModel.Testsdotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov ./tests/Api.WithReact.Testsreportgenerator "-reports:./tests/**/*.info" "-targetdir:coverage"
Frontend report:
yarn test --coverage