1. First Testbench Tutorial¶
Running a First Test Bench¶
Let’s create our first testbench and explore the basic concept of the test plan.
Create a file called main.py
in the folder in which you installed spintop-openhtf and copy this code.
Basic Testbench¶
# main.py
from openhtf.plugs.user_input import UserInput
from spintop_openhtf import TestPlan
""" Test Plan """
# This defines the name of the testbench.
plan = TestPlan('hello')
@plan.testcase('Hello-Test')
@plan.plug(prompts=UserInput)
def hello_world(test, prompts):
prompts.prompt('Hello Operator!')
test.dut_id = 'hello' # Manually set the DUT Id to same value every test
if __name__ == '__main__':
plan.no_trigger()
plan.run()
In the code above, a test plan is first declared.
plan = TestPlan('hello')
Then, a test case is declared and added to the test plan.
@plan.testcase('Hello-Test')
@plan.plug(prompts=UserInput)
def hello_world(test, prompts):
prompts.prompt('Hello Operator!')
test.dut_id = 'hello' # Manually set the DUT Id to same value every test
And finally the test plan is executed when the script is launched.
if __name__ == '__main__':
plan.no_trigger()
plan.run_console()
This simple test bench will simply interact with the operator by telling him Hello Operator!. Run it using the created virtual environment :
# Windows Activate
venv\Scripts\activate
python main.py
This test bench does not use the spintop-openhtf GUI therefore all interactions are made through the command line. The test prints Hello Operator! and indicates a PASS.
(venv) C:\GIT_TACK\doc_exp>python main.py
Hello Operator!
-->
================ test: hello outcome: PASS ================