Test Scripter keywords

Keyword

Explanation and usage 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

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

timeout 10000
priority

The priority value of the test case is 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

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

setresultdescription

Can be used to set description of currently executed test case. In case of an error situation, it will be shown in the test report.

setresultdescription object creation starts
create

Used to create a new instance of a test class. This keyword has two mandatory arguments:

  • Test class name : The test class name for the new object.
  • Test object name: The name of the created new instance of the test class.
create TestScriptClass test
createkernel

Used to create 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.
  • Test object name: The name of the created new instance of the kernel test class.
createkernel TSKernelTest test
delete

Used to delete 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 test
allownextresult

Used to add valid result values for a method and for asynchronous commands. The arguments for this keyword are Symbian OS 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

The allowerrorcodes keyword is used to add valid result values for a method and for asynchronous commands. The arguments for this keyword are Symbian OS 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

Used to pause 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 test
pause

Used to pause 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

Used to repeat 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
Object name

The test object name can be considered as a temporary keyword, which is valid between its creation with the create keyword and its deletion with the delete keyword. The object name is used to call methods from a test object. The method name is given as the first argument for the object name, and the method may have arguments, which are forwarded to the test class method.

TestObjectName MethodName

<method arguments 1 2 3>

oomignorefailure

Used for OOM testing. This keyword 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. This keyword 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. This keyword 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 value 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. This keyword 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

The testinterference keyword is used for test interference 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
testmeasurement

Used for test measurement testing. It can take the following arguments:

  • Command (start or stop)
  • Type
  • parameters
testmeasurement start stifmeasurementplugin02 c:\ConfigurationInfo.txt
. . .
testmeasurement stop stifmeasurementplugin02
callsub

The callsub command makes TestScripter executing pointed section of script.

A 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. There is possibility to 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

Used to request 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

Used to wait for an event. A request must be called before wait, and wait 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

Used to release 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

Used to set 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

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

unset Event1
bringtoforeground

The bringtoforeground keyword is used to bring UI component container to foreground.

sendtobackground

The sendtobackground keyword is used to send UI component container to background.

presskey

The presskey keyword is used to send key event to tested UI component. It has one mandatory parameter, which is the key code (a single character or constant defined in 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

The typetext keyword is used to send text to tested UI component. The text that should be sent to the UI components must be in quotation marks.

typetext “Text to send”