testIDEA and Python
Scripting and GUI are two ways of interaction with computers.
Advantages of scripting are flexibility and automation, while GUI
enables us quick start-up. This section describes how to connect
testIDEA and Python scripts, to get benefits of both worlds.
Scripts can be used for two different tasks. The first task is execution
of tests and analysis of results, the second task is extending
test functionality. Both tasks are described below.
Executing tests from Python
Tests should be run often to detect errors as soon as possible.
Furthermore, we also want to have more flexibility for configuring test
environment and the hardware which runs our application. These are
tasks for scripts. Now the main question arises - how can we reuse test
specifications created with testIDEA in scripting environment?
The answer is: By loading test specifications from test specification
file and executing it with the help of
winIDEA SDK. Detailed step by step instructions are given in
section
Executing tests with Python scripts.
Extending test functionality
If complexity of our test cases exceeds testIDEA capabilities, we can
extend tests with Python functions, which offer us full flexibility of
a programming language. For example, if function on target calculates
Fourier transform of a signal, it is very tedious to type values one by
one into test specification. By implementing verification with Python
script, we can verify calculations done on the target by independent
Python calculation.
winIDEA SDK contains several points during test execution, where
custom scripts can be executed. They can be used to:
- filter tests for execution
- initialize target state (test specification tag
initTarget
)
- initialize global variables and function parameters (test specification tag
initFunc
)
- verify test results (test specification tag
endFunc
)
- simulate behavior of stubbed functions (test specification tag
script
in section stubs
)
- restore target state (test specification tag
restoreTarget
)
Instructions for implementation and usage of script extensions are given in section
Writing Script Extensions.