Golden Tests¶
Golden tests ensure your TextFSM templates remain stable and correct over time.
A golden test consists of:
- a template (
.template) - an input text file (
.txt) - an expected output file (
.json)
Directory structure¶
tests/golden/
show_ip_interface/
template
input.txt
expected.json
Run all golden tests¶
pytest -k golden
Why golden tests?¶
- Prevent regressions
- Ensure template stability
- Document expected behavior
- Provide fast feedback during development
Writing a new golden test¶
- Create a folder under
tests/golden/ - Add:
templateinput.txtexpected.json- Run:
pytest -k golden --update