Test harness#

A test harness is a particular operator that can be declared only in a test module (*.swant) and with the following specificities:

  • It has no declared I/Os.

  • It has one implicit input _current_cycle: uint64; intended to contain the current cycle counter.

  • It has one implicit output _stop_condition: bool default=false; when it’s True, intended to indicate that the execution can be suspended or stopped.

  • It cannot be instantiated.

  • It must provide definitions for all sensors used in its cone of influence.

To include a test harness in a Test module, use the TestModuleCreator.add_test_harness() method.

TestHarness class#

../../_images/diagram1.svg

Fig. 20 Diagram class diagram for Test harness#

class ansys.scadeone.core.swan.TestHarness(id: Identifier, body: Scope | Equation | Callable | None, pragmas: List[Pragma] | None = None)#

Bases: Declaration, ModuleItem, TestHarnessDiagramCreator

Test harness definition.

get_full_path() str#

Full path of Swan construct.

static set_owner(owner: SwanItem | IModel | None, children: SwanItem | Iterable[SwanItem] | None) None#

Helper to set owner as the owner of each item in the Iterable items.

Parameters:
ownerSwanItem

Owner of the items.

childrenUnion[SwanItem, Iterable[SwanItem], None]

Items to set owner.

property body: Scope | Equation | None#

Harness body: a scope, an equation, or None.

property id: Identifier#

Language item identifier.

property is_protected: bool#

Tell if a construct item is syntactically protected with some markup and is stored as a string (without the markup).

property model: IModel#

Return model containing the Swan item.

property module: ModuleBase | None#

Module containing the item.

Returns:

ModuleBase: module container, see ModuleBody and ModuleInterface or None if the object is itself a module.

property owner: SwanItem | IModel | None#

Owner of current Swan construct.

property pragmas: List[Pragma]#

List of pragmas.