# Output Callbacks URL: /output-callbacks Learn how to create structured test results with OpenHTF, covering JSON output and custom output mechanisms with detailed examples. Enable automatic test report generation in JSON or other formats. Tracking tests is crucial for traceability and analysis, especially in production environments. OpenHTF uses output callbacks to automatically generate reports, with a default JSON format that can be customized as needed. You can enable automatic test result export in the default JSON format. A `test_result.json` file is created after execution and saved in the execution directory. The pattern can use any field of the record, so one file per run is the usual choice: Format string expanded with the record's fields, a callable returning a path, or an open file object. Pretty-print indentation. `None` writes compact JSON. Default `True`: attachments are base64-encoded into the JSON. Set `False` to keep the file small when phases attach images or long logs. The general structure of an OpenHTF JSON record is as follows (full field list in the JSON format reference): `ConsoleSummary` prints the outcome and, on failure, every failed measurement with its value and validator. Useful while developing a test: Other built-ins: `callbacks.OutputToFile(pattern)` pickles the record, and `mfg_inspector.MfgInspector` converts it to Google's `TestRun` protobuf (`save_to_disk()` / `upload()`). Both live under `openhtf.output.callbacks`. Output callbacks run for every test, which makes them the right place to push records to a database instead of (or as well as) a file. TofuPilot's client is an output callback: Records land in a workspace with yield and Cpk per measurement — see Manufacturing Test Analytics. The same pattern fits any REST API or database driver, as the custom callback below shows. You can implement a custom output format by creating a function to handle the test record and adding it as an output callback if the built-in format doesn't meet your needs. Callbacks run in order after the test finishes. The output file will then be: