Previous Topic

Next Topic

Book Contents

Book Index

Developer guide

A command is a word or a series of words used in a Test Case (TC) to request an action.

You can assign the result of a command to a variable. Read more about variables at the bottom of the page.

Command

Description

Syntax

Parameters

Examples

exec

Executes the given command.

exec <command>

  • command - mandatory

The command to execute. Can be single line with " and multi-line with """. Multi-line is used, when command to execute contains other quotes.

exec "fw.list"
exec """
kitman.i "Log Service Demo"
"""

assertEquals

Asserts that the expected message is available in the current output and clears - the output.

Note: that it matches the full output.

assertEquals [timeout] <assert_message> <expected_message>

  • timeout - optional

Time interval in seconds.

  • assert message - mandatory

If expected message and actual message are different, a message is thrown with the given message.

  • expected message - mandatory

Expected value. Can be single-line with " and multi-line with """.

Example 1
assertEquals "enable command without parameters return unexpected info" "The argument #1 <String> of command 'enable' is required, but is not set."

Example 2
assertEquals 2 "inventory.ls command returns unexpected result" """
"Log Files"
"""

Example 3
assertEquals 1 "disable is not reflected in details info" """
Rule with UID: ConsoleCommandsTestRule was disabled.
ConsoleCommandsTestRule DISABLED
-------------------------------------------------------------
UID                      ConsoleCommandsTestRule
Name                     Console Commands Rule
Description              console commands test rule
Visibility               VISIBLE
"""

assertIndexOf

Asserts that the expected message can be found in the current output and clears this message.

Note: that it matches only a part of the output.

assertIndexOf [timeout] <assert_message> <part_of_expected message>

  • timeout - optional

Time interval in seconds.

  • assert message - mandatory

If actual message does not contain the expected message, a message is thrown with the given message.

  • part of expected message - mandatory

Part of the expected output.

Example 1
assertIndexOf 1 "event from removing ConsoleCommandsTestRule is missing" "ConsoleCommandsTestRule was removed."

Example 2
assertIndexOf 1 "event from removing ConsoleCommandsTestRule is missing" "ConsoleCommandsTestRule was removed."

Example 3
assertIndexOf "List all action module types return unexpected info." """

Module Type UID Label
----------------------------------------------------------
"""

assertRegEx

Asserts that the regex matches a string from the current output and clears the matching.

Note: that it matches only a part of the output.

assertRegEx [timeout] <assert_message> <regex>

  • timeout - optional

Time interval in seconds.

  • assert message - mandatory

If actual message does not contain the expected message, a message is thrown with the given message.

  • regex - mandatory

The regular expression to which expected output to be matched.

 

Example 1
assertRegEx 2 "events from run commands are not received" """

Automation Event Subscription : %subID%
-------------------------------------------------------------
uid                                 automation:rule:admin
operation.name                      statusChanged
rule.status.details                 NONE
objectClass                         (.)*
name                                Automation Rule Admin
rule.uid                            ConsoleCommandsTestRule
rule.status                         RUNNING
tags                                \[\]

Example 2
exec "fw.install %res.dir%/demo.test.permissions.bundle.jar"

assertRegEx "fw.install file command" "(.)*demo.test.permissions.bundle.jar was installed. Bundle ID is (\d+)"

if

...

endif

Conditional execution of test commands/scripts.

if condition

command1

...

commandN

endif

  • condition - mandatory

The boolean expression after the if command is called the condition. If it is true, then the immediately following indented commands get executed. If the condition is false, the indented commands are skipped.

There is only one logical operator who can be used- or (||).

This condition should be predefined variables about security mode and all execution environments.

Example 1
if %security%
exec "fw.i com.prosyst.mbs.util.inventory.jar"
exec "pa.ls"
exec "fw.uninstall com.prosyst.mbs.util.inventory"
endif

Example 2
if %J2SE-1.5% || %JavaSE/compact1%
exec scr.details
endif

set

Extracts the values of all regex groups in the variable. The matching is done on the current output.

set <regex> <var1 var2 ... varN>

  • regex - mandatory

The regular expression, who match the entire or part of actual output.

<var1 var2 ... varN> - mandatory Variables which you want to set via groups in regular expression.

exec "atm.sub Rule -a"
set "The ID of this subscription is: (\d+)." subA

clear

Clear of the current output

clear

exec "kitman.i Automation"
clear

sleep

Pause the execution and wait for some time.

sleep <timeout>

  • timeout - mandatory

The number of seconds to wait.

exec "fw.rs %bundleID%"
sleep 2

//

A comment is text that is ignored by TC when a script is executed.

You can use comments to describe what is happening in the script or make other kinds of notes.

// <text>

  • text - optional

 

Example 1
//precondition
exec "kitman.i Automation"

Example 2
//finally
exec "kitman.un Automation"

Variables

You can use variables in TC to store and manipulate values.

Predefined variables

There are a three types predefined variables, available for all scripts:

User defined variable

For example, the following statements create and initialize two variables, one named demoID and one named hostID:

exec "fw.install %res.dir%/demo.test.permissions.bundle.jar"

set ".*Bundle ID is (\d+)" demoID

exec "fw.install %res.dir%/host.jar"

set ".*Bundle ID is (\d+)" hostID

Scope refers to the visibility of variables. Variables exists only within the script that it is declared in.

For example, variable declared in install.txt TS is visible only in install.txt

Using variables

Variables are not available outside the file in which they are declared.

To use an already declared variable, should be used % in the beginning and end of the variable name.

exec "fw.bundle %demoID%"

Scope of variables

Scope refers to the visibility of variables. Variables exists only within the script that it is declared in.

For example, variable declared in install.txt TS is visible only in install.txt.