Testing a Command with Synthetic Files
Synthetic fixtures let a test exercise format boundaries and error reporting without using real personal or production data.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace the expected output
Provide three invented rows, one containing a quoted comma. Check the result using a reader aware of that format. CSV with embedded commas gives a concrete field shape.
Exercise a normal failure too
An intentionally missing fixture can verify error status and the absence of a completed output. See test setup and assertion for separating the created files from the command action.[1]
Create one input whose boundaries can be inspected
A text converter can be tested using a temporary directory and two invented rows. Include a file name with a space and one record with a comma inside a quoted field. Observe the output through the expected parser. See testing CSV with embedded commas.
File: field notes.csv
Data shape: header, quoted comma row, ordinary row
Run with an explicit argument list
Compare exit code, parsed records and diagnostics
Use an isolated writable location for side effects
Check that input bytes still match after the command. Verify created files and whether any partial output remains after failure. Keep examples with synthetic fields.