|
| 1 | +# Running the examples |
| 2 | + |
| 3 | +## Install dependencies |
| 4 | + |
| 5 | +Some examples have their own additional dependencies. They can be installed |
| 6 | +with the following command: |
| 7 | + |
| 8 | +``` |
| 9 | +# Activate your virtualenv if not already done. |
| 10 | +pip install pandas |
| 11 | +``` |
| 12 | + |
| 13 | +## Running the examples |
| 14 | + |
| 15 | +Each example can be run as a Python script, so for `measurements.py`: |
| 16 | + |
| 17 | +``` |
| 18 | +python examples/measurements.py |
| 19 | +``` |
| 20 | + |
| 21 | +Running the test will print the outcome on the terminal. You can examine |
| 22 | +the run's JSON file, generated in the working directory, to view the |
| 23 | +measurements for the run. This example generates a JSON output because it |
| 24 | +configures one via output callbacks; read on for more examples with other |
| 25 | +types of outputs. |
| 26 | + |
| 27 | +Some examples also have user prompts, you'll have to enter some text at the |
| 28 | +prompt to continue the example. |
| 29 | + |
| 30 | +## List of examples |
| 31 | + |
| 32 | +### Canonical examples |
| 33 | + |
| 34 | +1. [`hello_world.py`](hello_world.py): start here if learning how to write |
| 35 | + an OpenHTF test. |
| 36 | + Comments explain usage of basic OpenHTF features: measurements, phases, |
| 37 | + `TestApi` and the OpenHTF test, and output callbacks. |
| 38 | +2. [`measurements.py`](measurements.py): measurements are the canonical |
| 39 | + mechanism to record text or numeric parameters for a phase. |
| 40 | + This example walks you through defining measurements with pass-fail rules ("validators"), units, dimensions, and how to set the measurements from |
| 41 | + your phases. |
| 42 | +3. [`with_plugs.py`](with_plugs.py): how to define and subclass plugs, and |
| 43 | + use them in a phase. |
| 44 | +4. [`frontend_example.py`](frontend_example.py): How to use the OpenHTF web |
| 45 | + frontend in a test. This gives your test a GUI via the default browser on |
| 46 | + the system. |
| 47 | +5. [`all_the_things.py`](all_the_things.py): demonstates use of plugs, |
| 48 | + measurements, attachments and `PhaseOptions`. Multiple phases are sequenced |
| 49 | + via a `Test` and executed, with some output callbacks defined (JSON file, |
| 50 | + pickle file and console). |
| 51 | + |
| 52 | +### Feature showcases |
| 53 | + |
| 54 | +1. [`checkpoints.py`](checkpoints.py): checkpoints with measurements can be |
| 55 | + used to stop a test if any phase before the checkpoint had failed |
| 56 | + measurements. |
| 57 | + By default, failed measurements don't stop a test execution. |
| 58 | +2. [`stop_on_first_failure.py`](stop_on_first_failure.py): shows how to use |
| 59 | + `TestOptions`, in this case the `stop_on_first_failure` option, to |
| 60 | + customize test execution. |
| 61 | + Also shows how to set this via a `Configuration`. |
| 62 | +3. [`ignore_early_canceled_tests.py`](ignore_early_canceled_tests.py): shows |
| 63 | + how to customize output callbacks; in this case, JSON output. |
| 64 | +4. [`phase_groups.py`](phase_groups.py): phase groups can be used to combine |
| 65 | + phases with their own setup and teardown logic. |
| 66 | +5. [`repeat.py`](repeat.py): uses `openhtf.PhaseResult.REPEAT` to |
| 67 | + conditionally repeat execution of a phase in a test. |
0 commit comments