SECAI Core · phase 12 of 15
Unit test
The developer writes a simple 'pass/no pass' test for code. This ensures that a particular block of code performs the exact action intended, and provides the exact output expected.
The Explain card
- Plain English
- A unit test is a small, automated pass or fail check that one piece of code does exactly what it should, producing the exact output expected for a given input.
- Example
- A function is supposed to strip injection markers from user input before it reaches the model. A unit test feeds it a string containing "ignore previous instructions" and asserts the sanitised output no longer contains that phrase.
- Why it matters
- Security controls are code, and code breaks silently when someone refactors it. Unit tests turn "we think the filter works" into proof that runs on every build.
- Hook
- One block, one question, one yes or no.
Where it sits in the deck
Phase 12: Defensive Technologies and Secure Development Practices
Map defences directly to the attacks just catalogued — the technical controls, secure coding practices, and protective tools that harden AI and traditional systems alike.