Test Scripter keywords

Keyword

Explanation and examples

title

Describes the test case. This is mandatory for every test case and must be the first keyword. The description is placed after the keyword.

title Create, print, run example and delete
timeout

Specifies a timeout value for a test case. The timeout value is given in milliseconds. For example, a timeout of 10 seconds would be marked as:

timeout 10000
priority

Specifies the priority value of the test case. The value can be either an integer or the string "high", "normal" or "low". Negative values are low and positive values are high.

For example, –100 is low, 0 is normal, 100 is high, 1000 is very high:

priority high
priority 100
priority –100
priority 0
print

Specifies a description to print, for example, to print progress information to the UI. The printed description is placed after the print keyword, as in the example in Test scripts.

setresultdescription

Sets the description of the current executed test case. In case of an error situation, it will be shown in the test report.

setresultdescription object creation starts
create

Creates a new instance of a test class. This keyword has two mandatory arguments:

  • Test class name : The test class name for the new object. It is the first argument.
  • Test object name: The name of the created new instance of the test class.
create TestScriptClass testObject
createkernel

Creates a new instance of a kernel test class. This keyword has two mandatory arguments:

  • Kernel test class name: The kernel test class name for the new object. It is the first argument.
  • Test object name: The name of the created new instance of the kernel test class.
createkernel TSKernelTest testObject
delete

Deletes an instance of a test class. Keyword has one mandatory argument:

  • Test object name: The name of the instance of the test class that is deleted.
delete testObject
allownextresult

Adds valid result values for a method and for asynchronous commands. The arguments for this keyword are Symbian platform error codes.

The default value for the expected result is 0, and if a value is set with allownextresult, 0 is removed from the expected values.

A method may either return or leave with the specified result. Every method call removes all allowed results. That is, after every method call, the default value 0 is again the only expected result value. Multiple allownextresult keywords can be placed before a method call and before the waittestclass keyword.

allownextresult –1
allownextresult –1 -5 -12
allowerrorcodes

Adds valid result values for a method and for asynchronous commands. The arguments for this keyword are Symbian platform error codes.

As a default the expected result is 0 and if new value is set with allowerrorcodes, 0 will remain as an expected value. A method may either return or leave with the specified results. Every method call removes all allowed results. That is, after every method call, the default value 0 is again the only expected result value.

Multiple allowerrorcodes keywords can be placed before a method call and before the waittestclass keyword.

allowerrorcodes –1
allowerrorcodes –1 -5 -12
waittestclass

Pauses test case running until the specified test class object calls the Signal function to proceed with the test case execution again. Keyword has one mandatory argument:

  • Test object name: The name of the instance of the test class, which must call Signal() to proceed with the test case execution.
waittestclass testObject
pause

Pauses test case running for a specified timeout (in milliseconds). That is, no further lines of the test case file will be executed during that delay, but the thread is not halted; any user active objects may still be completed and their RunL() called.

For example, a pause of 10 seconds would be:

pause 10000
loop
endloop

Repeats a section of the test case file for the specified number of iterations. The section to be repeated is enclosed with the loop and endloop keywords. Nested loops are not supported. Available arguments are:

  • Loop times: The loop count, that is, the number of times that the loop is executed.
  • msec (optional): This keyword says that ‘Loop times’ argument stands for the time in milliseconds during which loop will be repeated.

For example, to execute a loop for 5 times:

loop 5 // execute this 5 times
print LOOP_COUNTER // prints loop counter value, from 0 to -1.
endloop
oomignorefailure

Used for OOM testing. Defines if a test class’s building block execution result is checked or ignored. Possible values are ON or OFF:

  • ON indicates that the building block execution result will be ignored.
  • OFF (default) indicates that the building block execution result will be checked and errors will be handled.
oomignorefailure on
oomheapfailnext

Used for OOM testing. Defines that heap allocation failure occurs in the test thread.

  • Count value (rate): The failure rate. Heap allocation fails every time that is given as an argument. The given argument will be increased by one because the Test Scripter LOOP_COUNTER range starts from 0. The oomheapfailnext range starts from 1.
oomheapfailnext 0
oomheapsetfail

Used for OOM testing. Defines that heap allocation failure occurs in the test thread. The user can define the failure type and count (rate).

  • The type of failure to be simulated. The values are: random, truerandom, deterministic, none and failnext.
  • Count value (rate): The given argument will be increased by one because the Test Scripter LOOP_COUNTER range starts from 0. The oomheapsetfail range starts from 1.
oomheapsetfail deterministic 2
oomheaptonormal

Used for OOM testing. Ends OOM testing and normal testing continues. This keyword can be used to initialize OOM parameters to the default ones. The oomheaptonormal keyword enables the test class’s building block execution result check and heap failures are not used anymore.

testinterference

Interferes the testing. It can take the following arguments:

  • Object name
  • Command (start or stop)
  • Category
  • Type
  • Idle time (in milliseconds)
  • Active time (in milliseconds)
  • Set priority

Example of usage:

#idle = 200 microseconds, active = 2
microseconds testinterference object1 start activeobject cpuload 0.2 0.002
. . .
testinterference object1 stop
callsub

Makes TestScripter executing pointed section of script.

The section that will be called must start with [Sub name] and end with [EndSub] tags, where name is the identifier of the sub. The execution of the sub will continue until its end is reached. You can call a sub from another sub.

[Test]
title calldemo
print Starting...
callsub T1
callsub T2
print Finishing...
[Endtest]

[Sub T1]
print Inside T1 sub
callsub T11
[EndSub]

[Sub T11] print Inside T11 sub
[EndSub]

[Sub T2]
print Inside T2 sub
[EndSub]
request

Requests an event. If someone wants to use an event, it must first be requested, and after that it can be waited. After the event is not used anymore, it must be released. The event name is a mandatory parameter.

request Event1
wait

Waits for an event. A request must be called before wait, and wait on the requested event blocks until the requested event is set. wait may proceed immediately if the requested event is a state event and already pending (for example, a phone call is already active). wait has one mandatory argument, which is the event name.

wait Event1
release

Releases an event. Every requested event must be released explicitly when it is not used anymore. release has one mandatory argument, which is the event name.

release Event1
set

Sets an event. Every set state event must be explicitly unset. The arguments are:

  • Event: The event name.
  • State (Optional): If a state is given, sets the state event, otherwise sets an indication event. A state event remains set until it is unset explicitly with the unset keyword. An indication event is set only once to every requester and implicitly unset after that.

For example:

set Event1
set Event2 state
unset

Unsets a state event. Every set state event must be unset. Indication events cannot be unset. Unset of a event blocks until everyone who has requested the specified event has released the event. The mandatory argument is the event name.

unset Event1
bringtoforeground

Brings the UI component container to foreground.

sendtobackground

Sends the UI component container to background.

presskey

Sends a key event to the tested UI component. It has one mandatory parameter, which is the key code (a single character or constant defined in the TKeyCode enumeration).

Also other, optional parameters can be used.

presskey a
presskey 1
presskey EKeyDownArrow
presskey keycode=123
presskey keycode=EKeyDownArrow
presskey x modifier=EModifierShift
presskey keyscancode=123
presskey EKeyDevice0 // press left softkey
presskey local EKeyDevice0 // press left softkey
presskey global EKeyDevice0 // press left softkey
typetext

Sends text to the tested UI component. The text that should be sent to the UI components must be in double quotation marks.

typetext “Text to send”
measurement

Measures the testing.

Arguments:

  • Command for STF Test Measurement control.

    The supported values are:
    start for starting test measurement,
    stop for stopping test measurement.
    It also releases all allocated resources.

  • STF Test measurement type.

    The supported values are:
    measurementplugin01,
    measurementplugin02,
    measurementplugin03,
    measurementplugin04,
    measurementplugin05,
    bappeaprofiler

  • STF Test measurement module configuring, etc. user and test measurement module specific.
var

Assigns a text value to a specified variable. It can be then used in other parts of the script.

var Name Value

sendpointerevent

Sends pointer events to the tested UI component.

Arguments:

  • Event type: the pointer event type.

    The following pointer even types are surpported:
    EButton1,
    EButton2,
    EButton3,
    EPointerMove,
    EPointerSwitchOn,
    EButton1Down,
    EButton1Up,
    EButton2Down,
    EButton2Up,
    EButton3Down,
    EButton3Up

  • x: Pointer x co-ordinate
  • y: Pointer y co-ordinate

sendpointerevent EventType Xco-ordinate Yco-ordinate

using

Loads an STF specific test harness library.

Arguments:

  • DLL name: The test harness library name.
  • DLL object name: The alias of the created new instance of the test harness library.
expectedpanic

Declares a valid panic resume value for the test case.

Arguments:

  • Panic Number, an single integer, which represents the expected panic number

expectedpanic XXXX

createshareobj

Creates an object, wihch can be shared with other test cases in the same test script file.

Arguments:

  • Test Class Name: The test class name for the new object. This is the first argument.
  • Test Object Name: the name of the created new instance of the test class

createshareobj ClassName ObjName

restoreshareobj

Restores an object, which has been created by the createshareobj keyword.

Arguments:

  • Test Object Name: the name of the instance of the test class
deleteshareobj

Deletes an instance of a test class created with createshareobj.

Arguments:

  • Test Object Name: the name of the instance of the test class
file

Specifies a data file name.

Arguments:

  • sectionfile.ini: the data file name
  • da: a short name used in the script to reference the data file
section

Specifies which section in the data file will be referred to by the test case.

Arguments:

  • SectionName: The section name defined in the data file.
  • SectionShortName: The short name (optional).
canceliferror

Cancels the execution of the remaining test cases if one of the executed test cases has failed. This keyword is normally used to stop the test case execution when some of the test cases are long running.

[Test]
title Simple test case with canceliferror keyword
canceliferror
run testclass1 myConfig.cfg 1 // test case fails
run testclass2 mySecondConfig.cfg 2 // long running test case
[Endtest]
run

Starts a specified test case. It has several mandatory and optional arguments. The mandatory arguments are:

  • testmodule: The test module name.
  • configfile: The test case configuration file.
  • test case number: The test case number to be executed from configfile.

Optional arguments contain, for example, testid (identification for the test case), ini (initialization file for the test module) and category (normal, leave, panic, exception or timeout).

For example:

run netmodule net.cfg 5 testid=test1 expect=3 ini=ini.txt

run netmodule net.cfg -1 testid=test1 “title=My test case example”
cancel

Cancels a running test case. The test case is cancelled by immediately killing the thread that executes the test case. The keyword has one mandatory argument, the test ID.

cancel test1
pausetest

Pauses a test case. The test case is paused by pausing the thread that executes the test case. The pausetest keyword has one mandatory argument.

pausetest testid time

Arguments:

  • testid: the test ID from the run command.
  • time: (optional) Pause time in milliseconds. After this time, resume is called automatically (if not given, resume needs to be called explicitly).

For example:

pausetest test1 time=10

resume

Resumes a paused test case. Has one mandatory argument, the test ID.

resume test1
complete

Waits and blocks a running test case. This keyword is used to have a started test case wait to complete and blocks until the test case has finished. Has one mandatory argument, the test ID.

complete test1
allocate

Allocates a slave, for example, for running a test case on a remote phone. It uses Remote Control Protocol (RPC). The slave must always be allocated first before it can be used.

  • Slave type: The type of the slave. STF only supports slave phone. phone indicates that slave phone is also running STF. Other types must be handled by the slave implementation, that is, when implementing separate support for external network simulator.
  • Slave name: A unique name for the slave.

For example:

allocate phone MySlave
free

Frees a slave. Every allocated slave must be freed with free when it becomes unused. It has one mandatory argument, the slave name.

free MySlave
remote

Starts the execution of a test case in a slave and also requests and releases events from the slave. Other controlling for remote test cases is done with the same keywords as for the local test cases.

  • Slave name: The slave name, the same that was given for allocate.
  • Command name : The remote command name (supported: run, request, wait, set, unset, release).

For example:

remote MySlave run netmodule net.cfg 5 testid=test1 expect=3 ini=ini.txt
remote MySlave request Event1
remote MySlave wait Event1
remote MySlave set Event1
remote MySlave unsetEvent1
remote MySlave release Event1
INCLUDE

Includes a file

  • Must be written in capital letters and must start from the first column of the line.
  • File name (with path and extension) must follow INCLUDE tr. Rest of line would be ignored.
  • All files included from Unicode file should also be in Unicode format (and vice versa).
  • Loops in includes are not allowed (for example incorrect situation is when file A includes file B and file B includes file A). In that case, the second include will be ignored, but STF parser will continue working).