Skip to content

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

  1. Create a folder under tests/golden/
  2. Add:
  3. template
  4. input.txt
  5. expected.json
  6. Run:
pytest -k golden --update