Use this documentation to run tests locally.
All .NET code is unit tested where possible (as per the test approach).
You can run unit tests using your preferred IDE, or open a terminal in the project directory and run:
dotnet test
Note
The FIAT db tests will fail unless the Docker engine is running - see ADR 15. Use Test Containers to unit test FIAT database configuration, usages and change tracking on why and how this works.
-
Open a terminal in your repository and run:
# go to the cypress tests folder cd tests/DFE.FindInformationAcademiesTrusts.CypressTests # install dependencies npm install # set up Cypress npx cypress open #This will run Cypress for the first time and notify you of such, it should then setup Cypress locally for you.
-
Create a file in tests/DFE.FindInformationAcademiesTrusts.CypressTests called
cypress.env.json
which contains the following:{ "URL": "<url of the application under test>", "AUTH_KEY": "<auth bypass secret for application>" }
-
Make sure your
cypress.env.json
file contains the correct information for the environment you want to use. -
Open a terminal in your repository and run:
# go to the cypress tests folder cd tests/DFE.FindInformationAcademiesTrusts.CypressTests # run tests npx cypress open
-
You should now see the Cypress UI open
- click the e2e test option
- click the browser you want to test in
-
You should now see your test specs - to run these you click on the test spec and it should then run all the tests within said spec.
- If the test passes you should see a green tick next to said test with confirmation that all tests within the spec are passing if multiple.
- If the test fails it should show you within the runner what the failed test step is with a screenshot of where it failed to help you in debugging the fail. (N.b Cypress will rerun the open spec everytime you save one of your open files)
-
Set the
TestOverride__CypressTestSecret
value indocker/.env
to any value that you like -
Update your
cypress.env.json
to:{ "URL": "localhost", "AUTH_KEY": "<the TestOverride__CypressTestSecret value you set in step 2>" }
-
Open a terminal in your repository and run:
# go to the cypress tests folder cd tests/DFE.FindInformationAcademiesTrusts.CypressTests # run tests npx cypress open