Utility Examples

This page contains different examples of Utilities. The source code of those examples can be found in the ecu.test installation directory under Help/api/ExampleUtilities.

TSLinSpaceExample

class TsLinspaceExample

This is a small example on how a AXSUtility can be implemented.

ID = 'dd7b2b14-7b18-4234-9758-9eacdebc6f40'

A universally unique identifier to make your utility unique. The ID should be generated automatically to be unique.

Type:

UUID

Info

Setting this field is mandatory

NAME = 'TsLinspaceExample'

The display name of your utility.

Type:

str

Info

Setting this field is mandatory

DESCRIPTION = 'This is a small example of how an AXSUtility can be implemented (equidistant list).'

A short description of your utility that is displayed in the utilities tab.

Type:

str

Info

Setting this field is optional

classmethod GetInterface()

Return an interface which specifies our arguments.

OnPreProcess(testEngine)

Overwrite to implement pre execution behavior. This methode is called before running the test case.

OnRun(userExcInst, testEngine)

Implementation of the simple calculation.

GetReportInfos()

Overwrite to add custom information in the test report.

Returns:

Dictionary containing key value pairs to be shown in the report

Return type:

dict{str:str}

RunDialogExample

class RunDialogExample
OnOk(event)
SetValue(name, value)
GetValue(name)

TsShowDialogExample

class TsShowDialogExample
ID = '4c69cb5e-233a-11dd-b764-001c23232a0e'

A universally unique identifier to make your utility unique. The ID should be generated automatically to be unique.

Type:

UUID

Info

Setting this field is mandatory

NAME = 'ShowDialogExample'

The display name of your utility.

Type:

str

Info

Setting this field is mandatory

DESCRIPTION = 'Demonstrates how to show and interact with a dialog during runtime.'

A short description of your utility that is displayed in the utilities tab.

Type:

str

Info

Setting this field is optional

UtilityReport(reportEngine, reportDataObject)

The count value of the RunDialogExample that was shown during test execution is displayed in the test report.

OnRun(reportDataObject)

Here is demonstrated how a dialog can be shown during test execution. Due to execution in a separate thread the ThreadDialog class has to be used.

TsSimpleCalculationExample

class TsSimpleCalculationExample

This is a small example on how a AXSUtility should be implemented.

ID = '5c256353-1dc4-4651-8faf-af0e58dfe636'

A universally unique identifier to make your utility unique. The ID should be generated automatically to be unique.

Type:

UUID

Info

Setting this field is mandatory

NAME = 'SimpleCalculationExample'

The display name of your utility.

Type:

str

Info

Setting this field is mandatory

DESCRIPTION = 'This is a small example on how an AXSUtility should be implemented (simple calculation).'

A short description of your utility that is displayed in the utilities tab.

Type:

str

Info

Setting this field is optional

Addition(a, b)

Addition of 2 values.

Subtraction(a, b)

Subtraction of 2 values.

Multiplication(a, b)

Multiplication of 2 values.

Division(a, b)

Division of 2 values.

static GetBitmap()

Return the utility-icon.

Return type:

wx.Bitmap

classmethod GetInterface()

Return an interface which specifies our arguments.

OnRun(userExcInst, testEngine)

Implementation of the simple calculation.

GetReportInfos()

Overwrite to add custom information in the test report.

Returns:

Dictionary containing key value pairs to be shown in the report

Return type:

dict{str:str}

DlgSmallExample

class DlgSmallExample
OnCmdCancelButton(event)
OnCmdOkButton(event)

TsSmallExample

class TsSmallExample

This is a small example on how a utility should be implemented.

ID = '2dcc6e40-3859-11dd-82ff-000b5d5f5cc8'

A universally unique identifier to make your utility unique. The ID should be generated automatically to be unique.

Type:

UUID

Info

Setting this field is mandatory

NAME = 'SmallExample'

The display name of your utility.

Type:

str

Info

Setting this field is mandatory

DESCRIPTION = 'This is a small example that copies the value of one variable to another.'

A short description of your utility that is displayed in the utilities tab.

Type:

str

Info

Setting this field is optional

SERIALIZE : dict[str, tuple[str, str] | tuple[str, str, Any]] = {'varFrom': ('VARIABLENAME-FROM', 'string'), 'varTo': ('VARIABLENAME-TO', 'string')}

Here the two instance variables are declared for serialization.

UtilityInit()

Initialize the instance variables for the names of the two ecu.test variables used in this example.

UtilityReport(reportEngine, reportDataObject)

Specifies how the runtime data and other informations about this teststep are displayed in the test report.

GetDialog()

Returs the configuration dialog object of the Utility. The dialog needs a reference to the teststep for getting and setting the teststep data.

Return type:

DlgSmallExample

Returns:

Dialog object

GetUsedVariableNames()

Overwritten to specify the used variable names.

Return type:

list

Returns:

List of variable names used by this test step.

OnRun(reportDataObject)

Here the value from one to another variable is copied and the copied value is stored in RdoUserUtility to be available later on in the UtilityReport() method.