mkdir TemaEnv && cd TemaEnv
git clone https://github.com/hessuvi/tema-deployment-example.git
cd tema-deployment-example
./private_installation.shThe system may wait for around half a minute after the following text appears: Adapter: Waiting for a connection from a client.
This ensures that the test model has time for proper initialisation.
cd TestEnv
./tema-exec-test.sh ../ExampleModelPackage.zip ../canvas-adapter.py Ruut- Start ModelDesigner with command “tema.modeldesigner”
- Import ExampleModelPackage.zip into Modeldesigner (File->Import domain)
The example adaptor is implemented in files
- canvas-adapter.py
- contains main program and specialised Target and TestRunner classes. See documentation of tema-adapterlib.
- kw_generic.py
- contains implementation for commonly used keywords which are not dependent from target.
- kw_tkinter.py
- contains implementations of target specific keywords which require special libraries (here tkinter).
- Action word
- Logical operation to be performed. As a transition label, it start with prefix “aw_”
- State verification
- Special action word which is supposed to success and which do not change state of the test target. (Prefix: “sv_”)
- Keyword
- Concrete operation actually performed in a test target or its environment. Any action word is mapped in a model into a simple state machine which uses keywords as transition labels. (Prefix: “kw_”)
The base library for adapters implemented in python is tema-adapterlib. It defines classes Target, TestRunner, and Keyword. Files canvas_adapter.py and kw_*.py provide a simple example implementation of functional adapter.
The adapter can be run in three different modes.
- Interactive mode (command line option -i) listens keywords from standard input. The keywords should be given without prefix.
- Batch mode (command line option -f <file>) reads keywords from given file.
- Socket mode (command line option -a <host> -p <port>) has interactive conversation with a test generation engine. The test generation engine have to be started before adapter.
A test target name is a mandatory argument, but it need not have any meaning. Actual test targets names are defined when connections to the systems under test are initialised.
A short help can be obtained with option -h.
(Note: During an actual test run, the target name should refer to a device defined within the model library.)
A TestRunner object is an multiplexer which directs arriving keywords to a test target which is currently active. It has an internal keyword “settarget” which change the active target.
The actual test runner is supposed to be derived from class TestRunner. Methods _setupTestAutomation() and _cleanupTestAutomation have to be implemented. The method _setupTestAutomation is supposed to initialise connections to a test targets and append corresponding target objects into list _targets (attribute of test runner object). An attribute _targetNames is a list of names defined at command line of adapter. The method _cleanupTestAutomation is called when test execution is about to end.
A Target objects are open connections to systems under test. They are recognised with a name attribute which is defined at initialisation.
There is one class for each keyword used in a models. The keyword classes shall be subclasses of class Keyword. Each keyword class shall define a regular expression pattern which parses parameters of the keyword, in its __init__method. Also, a method execute have to be implemented. It actually executes the keyword at SUT and returns True or False whether execution was successful or not.
An adapter is started by parsing command line arguments, creating test runner object and entering into adapter main. See the end of the file canvas_adapter.py.
In the directory TestEnv, there is the script “tema-exec-test.sh”. Go to that directory and execute command
./tema-exec-test.sh ../../ExampleModelPackage.zipThere is no need to define the adapter and target name, since the generated test will be executed against the model itself.
The command starts a simulated test run, where user clicks the actions words to execute. Whenever test generator suggests a key word for execution, user is asked whether the key word is succeeding or not.