Create your first test
Let's create a first test script in under five minutes.
Installation
Install OpenHTF and its dependencies using pip:
pip install openhtf six setuptools
We recommend setting up a Python virtual environment to better manage dependencies.
First run
Create a main.py file in your virtual environment and copy this code.
main.py
import openhtf as htf
def hello_world(test):              # Define "hello_world" phase
    print('Hello world!')
    return htf.PhaseResult.CONTINUE # Continue to next phase
def main():
    test = htf.Test(hello_world)    # Define test with hello_world
    test.execute(lambda: "SN1234")  # Execute with DUT serial
if __name__ == '__main__':
    main()                          # Run main function
Run it with:
Terminal
python main.py
Terminal
(venv) C:\tofupilot > python main.py
Hello world!
======================= test: openhtf_test  outcome: PASS ======================
This is a very simple OpenHTF test, running through the command line without the Operator UI yet. You'll learn to connect instruments, add measurements, and more in the next sections.