Integration tests with TangoEventTracer
The module ska_tango_testing.integration provides a set of tools
to write integration tests for Tango devices using an event-driven approach.
Essentially this module gives you a relatively
simple and well tested code to capture events from Tango devices and then make
assertions on them, without the need to re-write the subscribe_event logic
or to rely to while ... sleep loops to wait for events.
Advantages and differences with other tools
Compared to the other tools that this library offers, like “event recorders”
or ska_tango_testing.mock, this module’s tools provide a more
simplified, concise and high-level way to capture and assert events especially
useful for integration tests where mocks are not needed.
If you are looking for a more low-level and flexible
approach to test asynchronous behaviours, you may want to look at the
ska_tango_testing.mock module. If instead you are writing integration
tests and you need to verify from outside that an SUT produces
certain change events,
then ska_tango_testing.integration probably is the right choice.
Being encapsulated in a library this tool has also the advantage of being already unit tested and potentially shared among different projects, without code duplication.
Module content overview
The central tool provided by the module is
TangoEventTracer,
which is a class that can be used to subscribe to device
attributes change events, store them locally and then make assertions over
them using the library
assertpy and some additional
custom assertions provided by the module itself (see
assertions).
This module provides also some additional event live-logging utilities, to help you debugging your tests.
To begin using ska_tango_testing.integration we recommend starting
with the Getting started with TangoEventTracer guide, to learn about
TangoEventTracer and how it can
be used to capture events and make assertions. Then, we recommend to read
Advanced Use Cases for the Assertions to learn about the full set of features of the
tracer and the assertions. If you are looking for more technical use-cases
and examples, you can refer to the Custom queries and assertions using TangoEventTracer guide
and finally to the API reference.
Integration tests with TangoEventTracer