Some examples have their own additional dependencies. They can be installed with the following command:
# Activate your virtualenv if not already done.
pip install pandas
Each example can be run as a Python script, so for measurements.py
:
python examples/measurements.py
Running the test will print the outcome on the terminal. You can examine the run's JSON file, generated in the working directory, to view the measurements for the run. This example generates a JSON output because it configures one via output callbacks; read on for more examples with other types of outputs.
Some examples also have user prompts, you'll have to enter some text at the prompt to continue the example.
hello_world.py
: start here if learning how to write an OpenHTF test. Comments explain usage of basic OpenHTF features: measurements, phases,TestApi
and the OpenHTF test, and output callbacks.measurements.py
: measurements are the canonical mechanism to record text or numeric parameters for a phase. This example walks you through defining measurements with pass-fail rules ("validators"), units, dimensions, and how to set the measurements from your phases.with_plugs.py
: how to define and subclass plugs, and use them in a phase.frontend_example.py
: How to use the OpenHTF web frontend in a test. This gives your test a GUI via the default browser on the system.all_the_things.py
: demonstates use of plugs, measurements, attachments andPhaseOptions
. Multiple phases are sequenced via aTest
and executed, with some output callbacks defined (JSON file, pickle file and console).
checkpoints.py
: checkpoints with measurements can be used to stop a test if any phase before the checkpoint had failed measurements. By default, failed measurements don't stop a test execution.stop_on_first_failure.py
: shows how to useTestOptions
, in this case thestop_on_first_failure
option, to customize test execution. Also shows how to set this via aConfiguration
.ignore_early_canceled_tests.py
: shows how to customize output callbacks; in this case, JSON output.phase_groups.py
: phase groups can be used to combine phases with their own setup and teardown logic.repeat.py
: usesopenhtf.PhaseResult.REPEAT
to conditionally repeat execution of a phase in a test.