Test Record
Complete reference for the OpenHTF test record structure including test outcomes, phase records, measurement data, attachments, and diagnosis results.
Understand the complete test record that OpenHTF produces after every test execution.
The test record holds the device identifier, the test outcome, one record per phase with its measurements and attachments, the log records and the diagnoses produced during the test.
- TestRecord
- dut_id
- outcome
- phases[]
- measurements
- attachments
- log_records[]
- diagnoses[]
Every test execution produces a TestRecord — a structured object containing everything that happened: outcomes, measurements, phase results, logs, attachments, and diagnoses. Output callbacks receive this record to write JSON, send to a database, or integrate with systems like TofuPilot.
Test record structure
dut_idstrSerial number or identifier of the device under test.
station_idstrIdentifier of the test station that ran the test.
outcomeOutcomeOverall test result: PASS, FAIL, ERROR, TIMEOUT, or ABORTED.
outcome_detailslist[OutcomeDetails]Additional context for the outcome, such as which phase caused a failure.
start_time_millisintTest start timestamp in milliseconds since epoch.
end_time_millisintTest end timestamp in milliseconds since epoch.
phaseslist[PhaseRecord]Ordered list of phase execution records.
log_recordslist[LogRecord]All log entries captured during test execution.
metadatadictTest-wide metadata set via test.configure(name=...) or directly.
diagnoseslist[Diagnosis]All diagnosis results from phase and test diagnosers.
marginalbool or NoneWhether the test passed but with marginal measurements.
Test outcomes
Outcome.PASSAll phases passed and all measurements met their validators.
Outcome.FAILOne or more measurements failed validation, or a phase returned STOP or FAIL_AND_CONTINUE.
Outcome.ERRORAn unhandled exception occurred during test execution.
Outcome.TIMEOUTA phase exceeded its timeout_s setting.
Outcome.ABORTEDThe operator or system aborted the test before completion.
Phase records
Each phase produces a PhaseRecord with its own outcome and measurements.
namestrPhase function name or overridden name from PhaseOptions.
outcomePhaseOutcomePhase-level outcome: PASS, FAIL, SKIP, or ERROR.
resultPhaseResultThe PhaseResult returned by the phase function.
measurementsdictMapping of measurement names to their outcomes and values.
start_time_millisintPhase start timestamp.
end_time_millisintPhase end timestamp.
codeinfoCodeInfoSource code and location of the phase function.
Accessing the record
You can access the test record directly within a phase through test.test_record, though this is generally discouraged in favor of using the test.measurements interface.
import openhtf as htf
def inspect_phase(test):
# Access test-level metadata
test.test_record.metadata['operator'] = 'Jane'
# Check DUT ID
test.logger.info('Testing DUT: %s', test.dut_id)
return htf.PhaseResult.CONTINUE
def main():
test = htf.Test(inspect_phase)
test.execute(lambda: "SN1234")
if __name__ == "__main__":
main()JSON output
The most common way to inspect a test record is via JSON output. See Output Callbacks for details on writing test records to files.
import openhtf as htf
from openhtf.output.callbacks import json_factory
@htf.measures(htf.Measurement('voltage').in_range(3.0, 5.0))
def measure_voltage(test):
test.measurements.voltage = 3.3
def main():
test = htf.Test(measure_voltage)
test.add_output_callbacks(
json_factory.OutputToJSON('./test_result.json', indent=2)
)
test.execute(lambda: "SN1234")
if __name__ == "__main__":
main()The resulting JSON file contains the complete test record: DUT ID, station ID, outcome, all phase records with their measurements, logs, and timing data.