OpenHTF, the open-source hardware testing framework in Python
OpenHTF (Open Hardware Testing Framework) is an open-source Python framework for hardware testing, originally created at Google. Phases, measurements with limits, plugs for instruments, an operator UI and JSON test records.
OpenHTF is a Python framework for writing hardware test scripts: the functional, end-of-line and burn-in tests that decide whether a board or a product passes. It was originally created at Google and is used from design verification through validation to manufacturing.
This documentation is maintained by the team at TofuPilot, a plug-and-play database and analytics app for OpenHTF tests. It is independent from Google (see the disclaimer).
Start here
What is OpenHTF?
History, maintainers, who uses it, and what it is not.
Installation
pip, extras, supported Python versions.
First test
A running test in five minutes.
Tutorial
Measure a resistor with a simulated multimeter and power supply.
Examples
Every upstream example, runnable and explained.
Concepts
DUT, phase, measurement, plug, test record — the vocabulary.
How a test is built
OpenHTF tests are Python scripts that run a series of test steps on a Device Under Test (DUT), taking measurements along the way. The framework handles setup, execution and teardown, records everything, and produces a pass/fail outcome.
PhasesTest steps — plain Python functions — that perform actions and return pass, fail, or skip. Phases →
MeasurementsValues captured during phases, with optional validators (limits, regex, custom) that decide the outcome. Measurements →
PlugsReusable classes that wrap external hardware and software — instruments, the DUT's serial port, the operator. Plugs →
Test RecordStructured output with outcomes, measurements, logs and attachments, written by output callbacks to JSON or a database. Test Record →
import openhtf as htf
from openhtf.plugs import plug
from multimeter_plug import MultimeterPlug
@plug(multimeter=MultimeterPlug)
@htf.measures(
htf.Measurement("voltage")
.in_range(3.0, 3.5)
.with_units("V"))
def test_voltage(test, multimeter):
voltage = multimeter.measure_voltage()
test.measurements.voltage = voltage
def main():
test = htf.Test(test_voltage)
test.execute(lambda: "SN0001") # DUT S/N
if __name__ == "__main__":
main()from openhtf.plugs import BasePlug
class MultimeterPlug(BasePlug):
# Simulate connecting to the multimeter
def __init__(self):
self.connected = True
# Simulate measuring the voltage
def measure_voltage(self):
return 3.3
# Simulate disconnecting from the multimeter
# Called automatically by OpenHTF at test end
def tearDown(self):
self.connected = FalseGo deeper
Operator UI
Browser interface for the production floor.
Phase groups, checkpoints, subtests
Guaranteed teardown, early stop, isolated failures.
Instrument plugs
PyVISA, pyserial and pymodbus guides.
Reference
Units, validators, JSON format, CLI flags, bundled plugs.
OpenHTF vs pytest
When a hardware-specific framework pays off.
Manufacturing test analytics
Yield and Cpk per measurement with TofuPilot.