kbLogger 2.0.b1
The automotive ready test and logging program.
Test Class Reference

This class defines the API for the created tests.

#include <configitemtestobject.h>

Public Slots

Test related functions.
TestsetActive (bool bActive)
 Activate or deactivates the test.
 
TestsetBlockingMode (bool bBlockingMode)
 Activate or deactivates the blocking mode of the test.
 
TestsetFaultTolerance (bool bFaultTolerant)
 Activate or deactivates the fault tolerant mode.
 
TestsetChildFaultTolerance (bool bFaultTolerant)
 Activate or deactivates the child fault tolerant mode.
 
TestaddLink (Test *pLinkTarget, QString strTestName)
 Add a link as a SubTest to this test.
 
TestgetParent ()
 Retrieves the parent test related to this test.
 
TestgetChild (int testIndex)
 Retrieves the SubTest related to the current index (handle).
 
quint32 getChildCount ()
 Retrieves the count of SubTests of this test.
 
quint32 getRepeatCount ()
 Retrieves the RepeatCount.
 
quint32 getRemainingCount ()
 Retrieves to count of remaining test runs.
 
TestsetRepeatCount (quint32 uRepeatCount)
 Set the RepeatCount of this test.
 
TestsetRepeatCount (quint32 uRepeatCount, quint32 uRepeatDelay)
 Set the RepeatCount of this test.
 
TestsetRetryCount (quint32 uRetryCount)
 Set the RetryCount of this test.
 
TestsetRetryCount (quint32 uRetryCount, quint32 uRetrayDelay)
 Set the RetryCount of this test.
 
quint32 getTimeout ()
 Retrieves the timeout value of this test.
 
quint32 getRemainingTime ()
 Retrieves the remaining time until the timeout occurs.
 
TestsetTimeout (quint32 uTimeout)
 Sets the timeout.
 
int getState ()
 Retrieves the state of the test.
 
QString getTestName ()
 Retrieves the name of the test.
 
QString getTestInfo ()
 Retrieves the TestInfo.
 
TestsetTestInfo (QString strTestInfo)
 Sets the TestInfo.
 
QString getCallback ()
 Retrieves the test callback.
 
TestsetCallback (QString strTestCallback)
 Sets the test callback.
 
QString getFunction ()
 Retrieves the test function.
 
TestsetFunction (QString strTestFunction)
 Sets the test function.
 
TestConditioncreateCondition (quint32 uTimeout, QString strConditionName)
 Adds a condition to this test.
 
TestConditioncreateCondition (quint32 uTimeout, QString strConditionName, QString strRegExpPassed, QString strRegExpFailed="")
 Adds a condition to this test.
 
TestConditioncreateDelay (quint32 uTimeout, QString strConditionName, QString strRegExpDelay)
 Adds a delay condition to this test.
 
TestConditioncreateWatchDog (quint32 uTimeout, QString strConditionName, QString strRegExpWatchDog)
 Adds a watchdog condition to this test.
 
TestConditiongetCondition (QString strConditionName)
 Retrieves the condition of this test which is related to the condition name.
 
TestConditiongetCondition (int iConditionIndex)
 Retrieves the condition of this test which is related to the condition index.
 
QVariant getParameter (QString strParameter)
 Retrieves the value of the given parameter.
 
TestsetParameter (QString strParameter, QVariant vValue)
 Stores the given value as parameter.
 
void passed (QString strPassed)
 Sets the test state to passed.
 
void failed (QString strFailed)
 Sets the test state to failed.
 
quint32 getTime ()
 Retrieves the runtime of the TestCondition.
 
void storeMarker (QString strText)
 Stores a marker in the list of test events.
 
void storeFileMarker (QString strText, QString strFile)
 Stores a file marker in the list of test events.
 

Member Function Documentation

◆ addLink

Test * addLink ( Test * pLinkTarget,
QString strTestName )
slot

Add a link as a SubTest to this test. With this function, an existing test can be used in multiple parent tests.

Example:

var invisibleTest0 = to.createInvisibleTest("invisibleTest0", "invisibleTestFunction"); // Create an invisible test
var test0 = to.createTest("test0", "test0Function"); // Create the visible test
var subtest1 = test0.addLink(invisibleTest0, "myFancyLink"); // Add invisibleTest0 under a new TestName as SubTest to test0
Parameters
pLinkTargetA reference to the link target.
strTestNameThe new name under which the link target occurs as SubTest below the test.
Returns
A reference to the new SubTest (the link).

◆ createCondition [1/2]

TestCondition * createCondition ( quint32 uTimeout,
QString strCondName )
slot

Adds a condition to this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
var myCondition = test0.createCondition(0, "myCondition"); // Add a condition to the test
myCondition.setExpression("passedCondition", "failedCondition"); // Add the expressions to the condition
Parameters
uTimeout
strCondName
Returns
A reference to the TestCondition

◆ createCondition [2/2]

TestCondition * createCondition ( quint32 uTimeout,
QString strConditionName,
QString strRegExpPassed,
QString strRegExpFailed = "" )
slot

Adds a condition to this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
var myCondition = test0.createCondition(0, "myCondition", "QRegularExpression for passed", "QRegularExpression for failed"); // Add a condition to the test
Parameters
uTimeout
strConditionName
strRegExpPassed
strRegExpFailed
Returns
A reference to the TestCondition

◆ createDelay

TestCondition * createDelay ( quint32 uTimeout,
QString strConditionName,
QString strRegExpDelay )
slot

Adds a delay condition to this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
var myCondition = test0.createDelay(0, "myDelay", "QRegularExpression for delay trigger"); // Add a delay to the test
Parameters
uTimeout
strConditionName
strRegExpDelay
Returns
A reference to the TestCondition

◆ createWatchDog

TestCondition * createWatchDog ( quint32 uTimeout,
QString strConditionName,
QString strRegExpWatchDog )
slot

Adds a watchdog condition to this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
var myCondition = test0.createWatchDog(0, "myCondition", "QRegularExpression for watchdog trigger"); // Add a watchdog to the test
Parameters
uTimeout
strConditionName
strRegExpWatchDog
Returns
A reference to the TestCondition

◆ failed

void failed ( QString strFailed)
slot

Sets the test state to failed.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.failed("failed because of ..."); // Set the test to failed
Parameters
strFailedThe is text is shown in the test report when the test run is finished.

◆ getCallback

QString getCallback ( )
slot

Retrieves the TestCallback.

The test callback is called, if the test changes its state to PASSED, FAILED or TIMEOUT.

Returns
TestCallback

◆ getChild

Test * getChild ( int iChildIndex)
slot

Retrieves the SubTest related to the current index (handle).

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
var test1 = to.createTest(test0, "test1", "test1Function"); // Create a SubTest
var subtest = test0.getChild(0); // Get the first child (=test1)
Parameters
iChildIndexThe child index in the list of SubTests.
Returns
A reference to the searched child. 0 if not found.

◆ getChildCount

quint32 getChildCount ( )
slot

Retrieves the count of SubTests of this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
var test1 = to.createTest(test0, "test1", "test1Function"); // Create a SubTest
var nCilds = test0.getChildCount(); // Get the child count (=1)
Returns
The number of SubTests.

◆ getCondition [1/2]

TestCondition * getCondition ( int iConditionIndex)
slot

Retrieves the condition of this test which is related to the condition index.

Parameters
iConditionIndex
Returns
A reference to the TestCondition

◆ getCondition [2/2]

TestCondition * getCondition ( QString strConditionName)
slot

Retrieves the condition of this test which is related to the condition name.

Parameters
strConditionName
Returns
A reference to the TestCondition

◆ getFunction

QString getFunction ( )
slot

Retrieves the TestFunction.

The test function is called, if the test changes its state to RUN.

Returns
TestFunction

◆ getParameter

QVariant getParameter ( QString strParameter)
slot

Retrieves the value of the given parameter.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.setParameter("param", 42);
var myValue = test0.getParameter("param");
Parameters
strParameterThe name of the parameter
Returns
The value

◆ getParent

Test * getParent ( )
slot

Retrieves the parent test related to this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
var test1 = to.createTest(test0, "test1", "test1Function"); // Create a SubTest
var parenttest = test1.getParent(); // Get the parent (=test0)
Returns
A reference to the parent. 0 if there is no parent (this must be a top level test).

◆ getRemainingCount

quint32 getRemainingCount ( )
slot

Retrieves to count of remaining test runs.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.setRepeatCount(42); // Set the RepeatCount
var nRuns = test0.getRemainingCount(); // Get the remaining repeat count
Returns
The remaining repeat count

◆ getRemainingTime

quint32 getRemainingTime ( )
slot

Retrieves the remaining time until the timeout occurs.

Example:

var test0 = to.createTest("test0", "test0Function", 42); // Create a test with timeout 42
var time = test0.getRemainingTime(); // Get the remaining time
Returns
Remaining time if the test is running, otherwise -1.

◆ getRepeatCount

quint32 getRepeatCount ( )
slot

Retrieves the RepeatCount of this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.setRepeatCount(42); // Set the RepeatCount
var nRuns = test0.getRepeatCount(); // Get the repeat count (=42)
Returns
The RepeatCount.

◆ getState

int getState ( )
slot

Retrieves the state of the test.

Possible values are: TEST_INACTIVE = 0, TEST_ACTIVE = 1, TEST_RUNNING = 2, TEST_PAUSED = 3, TEST_PASSED = 4, TEST_FAILED = 5, TEST_DELAYED = 6, TEST_TIMEOUT = 7, TEST_CANCELED = 8, TEST_CANCELEDBYPARENT = 9, TEST_ERROR = 10

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
function test0Function(TestIndex)
{
var t = to.getTest(TestIndex);
var state = t.getState();
Returns
The state of the test

◆ getTestInfo

QString getTestInfo ( )
slot

Retrieves the TestInfo.

The test information are useful to store some informations about the background of the test. This information is not influencing anything of the test itself.

Returns
TestInfo

◆ getTestName

QString getTestName ( )
slot

Retrieves the TestName.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
function test0Function(TestIndex)
{
trace("invisibleTest0Case1Function(" + TestIndex + ")");
var t = to.getTest(TestIndex);
var name = t.getTestName();
var name = to.getTestName(TestIndex);
}
Returns
TestName

◆ getTime

quint32 getTime ( )
slot

Retrieves the runtime of the Test.

Returns
The runtime in ms.

◆ getTimeout

quint32 getTimeout ( )
slot

Retrieves the timeout value of this test.

Example:

var test0 = to.createTest("test0", "test0Function", 42); // Create a test with timeout 42
var timeout = test0.getTimeout(); // Get the timeout
Returns
Timeout

◆ passed

void passed ( QString strPassed)
slot

Sets the test state to passed.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.passed("passed because of ..."); // Set the test to passed
Parameters
strPassedThe is text is shown in the test report when the test run is finished.

◆ setActive

Test * setActive ( bool bActive)
slot

Activate or deactivates the test. Since the default activity state is true, it is not necessary to set this to true in the script. If you want to switch off a test and prevent that test from running in the test run, call this function with parameter bActivate=false.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create the test
test0.setActivate(false); // Deactivate the test
Parameters
bActiveSet to true to activate the test, otherwise set it to false.
Returns
Returns the test handle. NULL in case of an error.

◆ setBlockingMode

Test * setBlockingMode ( bool bBlockingMode)
slot

Activate or deactivates the blocking mode of the test. That means, if true, the parent test will wait starting the next child test until this test has finished. Example:

var invisibleTest0 = to.createInvisibleTest("invisibleTest0", "invisibleTestFunction"); // Create an invisible test
var invisibleTest0.setBlockingMode(true); // Set the blocking mode
Parameters
bBlockingModeSet to true, if the test shall running in blocking mode (default).
Returns
Returns the test handle.

◆ setCallback

Test * setCallback ( QString strTestCallback)
slot

Sets the TestCallback.

The test callback is called, if the test changes its state to PASSED, FAILED or TIMEOUT. Example:

var test0 = to.createTest("test0"); // Create a test
test0.setCallback("test0Callback"); // Add a test callback
function test0Callback(TestIndex)
{
trace("test0Callback(" + TestIndex + ")");
var t = to.getTest(TestIndex);
var state = t.getState();
}
Parameters
strTestCallback
Returns
The test handle;

◆ setChildFaultTolerance

Test * setChildFaultTolerance ( bool bFaultTolerant)
slot

Sets the child fault tolerance of the test. That means, if true, the test is continuing the next child test, in case a child test is failing. If false, the test is changing it's state to failed and informs its parent.

Example:

var invisibleTest0 = to.createInvisibleTest("invisibleTest0", "invisibleTestFunction"); // Create an invisible test
var invisibleTest0.setChildFaultTolerance(true); // Set the fault tolerance
var subtest1 = test0.addLink(invisibleTest0, "myFancyLink"); // Add invisibleTest0 under a new TestName as SubTest to test0
Parameters
bFaultTolerantSet to true, if the Test shall be tolerant to children faults.
Returns
Returns the test handle.

◆ setFaultTolerance

Test * setFaultTolerance ( bool bFaultTolerant)
slot

Sets the fault tolerance of the test. That means, if true, the test state is not influencing its parent state. If false, the test is changing it's state to failed and informs its parent.

Example:

var invisibleTest0 = to.createInvisibleTest("invisibleTest0", "invisibleTestFunction"); // Create an invisible test
var invisibleTest0.setFaultTolerance(true); // Set the fault tolerance
var subtest1 = test0.addLink(invisibleTest0, "myFancyLink"); // Add invisibleTest0 under a new TestName as SubTest to test0
Parameters
bFaultTolerantSet to true, if the Test shall be fault tolerant.
Returns
Returns the test handle.

◆ setFunction

Test * setFunction ( QString strTestFunction)
slot

Sets the TestFunction.

The test function is called, if the test changes its state to RUN. Example:

var test0 = to.createTest("test0"); // Create a test
test0.setFunction("test0Function"); // Add a test function
function test0Function(TestIndex)
{
trace("test0Function(" + TestIndex + ")");
}
Parameters
strTestFunction
Returns
The test handle.

◆ setParameter

Test * setParameter ( QString strParameter,
QVariant vValue )
slot

Stores the given value as parameter.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.setParameter("param1", 42).setParameter("param2", 4711);
var myValue1 = test0.getParameter("param1");
var myValue2 = test0.getParameter("param2");
Parameters
strParameterThe name of the parameter
vValueThe value of the parameter
Returns
The test handle itself

◆ setRepeatCount [1/2]

Test * setRepeatCount ( quint32 uRepeatCount)
slot

Set the RepeatCount of this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.setRepeatCount(42); // Set the RepeatCount
Parameters
uRepeatCount
Returns
Returns the test handle. NULL in case of an error.

◆ setRepeatCount [2/2]

Test * setRepeatCount ( quint32 uRepeatCount,
quint32 uRepeatDelay )
slot

Set the RepeatCount of this test.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.setRepeatCount(42, 100); // Set the RepeatCount
Parameters
uRepeatCount
uRepeatDelayin ms.
Returns
Returns the test handle. NULL in case of an error.

◆ setRetryCount [1/2]

Test * setRetryCount ( quint32 uRetryCount)
slot

Set the RetryCount of this test. If not called, the RetryCount is 0. Which means the test is running only once.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.setRetryCount(1); // Set the RetryCount
Parameters
uRetryCount
Returns
Returns the test handle. NULL in case of an error.

◆ setRetryCount [2/2]

Test * setRetryCount ( quint32 uRetryCount,
quint32 uRetryDelay )
slot

Set the RetryCount of this test. If not called, the RetryCount is 0. Which means the test is running only once.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test
test0.setRetryCount(1, 100); // Set the RetryCount
Parameters
uRetryCount
uRetryDelayin ms.
Returns
Returns the test handle. NULL in case of an error.

◆ setTestInfo

Test * setTestInfo ( QString strTestInfo)
slot

Sets the TestInfo.

The test information are useful to store some informations about the background of the test. This information is not influencing anything of the test itself.

Parameters
strTestInfo
Returns
The test handle.

◆ setTimeout

Test * setTimeout ( quint32 uTimeout)
slot

Sets the timeout.

Example:

var test0 = to.createTest("test0", "test0Function"); // Create a test without timeout
var timeout = test0.setTimeout(42); // Set the timeout to 42 ms
Parameters
uTimeout
Returns
The test handle.

◆ storeFileMarker

void storeFileMarker ( QString strText,
QString strFile )
slot

Stores a file marker in the list of test events.

The file is copied into the test result folder and the marker will also be visible in the generated HTML report as a link to the file.

Parameters
strTextThe user defined text for that marker.
strFileThe full qualified file name.

◆ storeMarker

void storeMarker ( QString strText)
slot

Stores a marker in the list of test events.

The marker will also be visible in the generated HTML report.

Parameters
strTextThe user defined text for that marker.