The ‘arrange, act, assert’ mantra is a pattern for structuring your unit tests (as well as integration tests and e2e tests).
The contents of a test should be partitioned into 3 parts in the following order:
Arrange – the setup code that’s required before you can test what you want to test.
Act – the code that executes what the test intends to do.
Assert – the code that makes assertions about what the aftermath should be.
Some simple, concrete examples of this pattern:
Unit testing a C++ function (using GoogleTest). This tests a SymbolTable class that’s meant to be used as a supporting data structure for a compiler project.
Unit testing a frontend React component (using Jest). This tests the breadcrumbs component on the portfolio website, timz.dev.
E2E testing a web app (using Cypress). This tests that the portfolio website, timz.dev, is able to load the about page via a link on the homepage.