Testing and guards
Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.
For agents
- Testing is proportional to risk and the lifetime of the code: a throwaway prototype does not need a full suite, a flow touching money or personal data does.
- A guard is a test that enforces a rule automatically; write one when the same bug appeared twice or when a rule is cheap to check and costly to break.
- A red test is never silenced: fix the code. Skipped or not measured counts as red.
Which class?
This topic has items from class S. The blocks below are cumulative: read up to your own class.
- S: 3 items
- M: 4 items
- L: 8 items
- XL: 2 items
Audit checklist
Every project
- Links, forms and main flows were checked by hand
- What: Before release someone opened the pages, clicked the links and used the forms or main flows.
- How to check: Look for a release checklist or test record; click through the main paths yourself.
- Evidence: Dated checklist or recorded run.
- Test effort matches risk and code lifetime
- What: Throwaway prototypes have few tests; flows touching money, identity or personal data have strong tests; the class of the project sets the minimum.
- How to check: Compare the test list with the project class and the risky flows.
- Evidence: Test inventory against the class table.
- Works at phone width
- What: Pages and screens are usable at 360 px width without sideways scrolling.
- How to check: Open the product at 360 px width (browser device mode or a real phone) and walk through the main pages.
- Evidence: Screenshots at phone width for the main pages.
+ If it has users, personal data or API keys (M)
- Critical flows have automated tests and a local check
- What: Login, saving data, payment (if any) and permission checks have automated tests; one local command runs the checks before pushing.
- How to check: List the test files; run the check command; look for a git hook that runs it.
- Evidence: Test names and a passing run log.
- Permissions are checked on the server
- What: Every action checks who the user is and what they may do on the server; a hidden button is not security.
- How to check: Call each protected endpoint without a session and with the wrong user; read the permission checks in the handlers.
- Evidence: Test names for unauthenticated and wrong-user requests; code lines of the checks.
- Secret scanning runs before push and in CI
- What: A scanner (for example gitleaks or secretlint) runs before code is pushed and in CI.
- How to check: Find the hook or CI step that runs the scanner.
- Evidence: Hook file or CI step; latest clean run.
- Skipped or unmeasured does not count as green
- What: “Skipped”, “not measured” and “timed out” are treated as failures, not successes.
- How to check: Search the test configuration for skip markers and the CI for allowed failures.
- Evidence: Search result; CI settings.
+ If it has an admin panel, file uploads, many users or a store app (L)
- End-to-end tests, short CI run, guards, screenshot checks
- What: End-to-end tests exist; a short run happens in CI; guards (tests that enforce rules) protect important rules; screen checks cover both themes and all languages; new end-to-end tests pass three runs in a row before merging; a red test is fixed in code, never silenced.
- How to check: Read the CI file and test folders; look for skipped tests and quarantined guards.
- Evidence: CI run, guard inventory, three-run log.
- All guards are in one inventory
- What: One document lists each guard and test type: what it protects, why it exists, when it runs, and what to do when it fails.
- How to check: Find the inventory; compare it with the real test and guard files.
- Evidence: Inventory document.
- Red tests are fixed in code, in a fixed order
- What: When a check fails: read the message first, fix the code (not the guard), change a guard only when a protected decision truly changed and say why in the guard, inventory and commit; never delete a guard silently.
- How to check: Read recent commits that touched tests or guards.
- Evidence: Commit messages with reasons.
- New or changed end-to-end tests run three times in a row
- What: Before merging, a new or changed end-to-end test must pass three consecutive runs; a failure in any run means finding the root cause.
- How to check: Look for a repeat-run step or a note in the change.
- Evidence: Three-run log.
- Small tasks check only what they touch; a big run happens before main
- What: During small tasks only the related package is checked; one large full test runs before sending to the main branch; long tests can resume where they stopped; local checks run before every push, enforced by a git hook.
- How to check: Read the contributing notes, hooks and CI.
- Evidence: Hook file; run records.
- Access to other users’ records is tested on every endpoint
- What: For each endpoint a test changes the identifier in the request and confirms the user cannot reach someone else’s data (IDOR/BOLA).
- How to check: List endpoints that take an ID; find the matching negative test for each.
- Evidence: Test names per endpoint.
- An accessibility guard and manual screen reader check exist (L+)
- What: Automated accessibility checks run in CI, and someone has used a screen reader on the main flows.
- How to check: Read the CI scan and find the manual test notes.
- Evidence: CI step; notes.
- Audits and big runs follow the rounds rule
- What: Before any long or costly run (load test, mass scan, cloud machine) the scenario is checked against the current code and a small smoke run is done; audit rounds fix findings first, then start a new full round.
- How to check: Read the last audit or load-test record.
- Evidence: Smoke-run log; round records.
+ If it targets millions of users (XL)
- New tests are proven by breaking the code
- What: When a new test is added, the code it protects is deliberately broken once and the test is shown to fail.
- How to check: Look for mutation test reports or notes in test commits.
- Evidence: Report or commit note showing the failing run.
- Load tests with a coverage map and an attack drill
- What: Load tests use real request patterns (burst, long run, writes, a huge account, a database restart, media upload, attack drill); every endpoint and scheduled job is in a coverage map; a new endpoint without a map entry fails a guard; with hit-rate “busy” responses at target steps counted as findings.
- How to check: Read the load test folder and the map; check the guard.
- Evidence: Latest run report; coverage map.
Common mistakes
- Writing a full test suite for a one-off script.
- No tests at all for login, saving data or payment.
- Disabling a failing test to get a green run.
- Changing a guard to make it pass instead of fixing the code.
- Calling a flaky test ‘just flaky’ instead of finding the cause.
- A test that can never fail because it never touched the protected code.
- Running the long test suite after every small change.
- Treating ‘skipped’ as success.
Sources
- Web Security Testing Guide — OWASP
- SP 800-218: SSDF Version 1.1 — NIST
- Concise Guide for Developing More Secure Software — OpenSSF
- REL12-BP03 Test scalability and performance requirements — AWS
- REL12-BP04 Test resiliency using chaos engineering — AWS
- Pro Build Guide v1.2: compiled team practices — Pro Build Guide