Operators ¶
intaQt supports most operations. Operations conform to Operation Precedence, in other words, the order of operations. For example, parentheses are used to force a given precedence. The results of the operations described above constitute additional expressions that can be reused in subsequent operations.
Examples¶
Feature File Example
1 2 3 4 5 | Feature: Operators Example Scenario: Adding And add numbers |
Steps File Example
1 2 3 4 5 6 | stepdef "add numbers" result := 4 * (2 + 3) - 3 % 2 result2 := 1 + result println(result + 1) println(result + result2) end |
Configuration File Example
1 | Glue.path : ["Project"] |
When this test case is run, it will print the following to the log:
1 2 3 4 5 | 2018.10.30 15:14:33.8 Scenario started: Adding 2018.10.30 15:14:33.8 Step started: add numbers 2018.10.30 15:14:33.8 20 2018.10.30 15:14:33.8 39 2018.10.30 15:14:33.8 Step ended with status: passed |
The order of precedence for Arithmetic Operations, ranging from highest to lowest, are:
Symbol | Operation |
---|---|
() |
Group |
% |
Modulo |
^ |
Exponential |
*, / |
Multiplication, Division |
+, - |
Addition, Subtraction |
The order of precedence for comparison and Logical Operations is:
-
<=
<
>
>=
-
= !=
-
and
-
or
Arithmetical Operations ¶
Operation | Symbol | Example | Result |
---|---|---|---|
Addition | + |
2 + 2.3 |
Number |
Addition with strings | + |
"hello" + " world" |
String |
Subtraction | - |
17 - 3 |
Number |
Multiplication | * |
2 * 4.1 |
Number |
Division | / |
102 / 12 |
Number |
Exponential | ^ |
10 ^ 3 |
Number |
Modulo | % |
10 % 3 |
Number |
Comparison and Logical Operations¶
Operator | Symbol | Example |
---|---|---|
Equals | == |
balance == 2 |
Not Equal | != |
balance != 1 |
Not | ! |
rate !5 |
Greater Than | > |
a > b |
Less Than | < |
b < a |
Greater Than or Equal | >= |
c >= d |
Less Than or Equal | <= |
d <= c |
And | and |
a and b |
And | && |
a && b |
Or | or |
a or b |
Or | | | a || b |
Bitwise Operators¶
Operator | Symbol | Example |
---|---|---|
Bitwise And | & |
E1 & E2 |
Bitwise Or | | |
E1 | E2 |
Bitwise Xor | ^ |
E1 ^ E2 |
Example
1 2 3 4 5 6 7 8 | cdrVerificationVariables { cdrSelectionA { "voiceAndSms" = "(Ticket_Type == 'SMS' || Ticket_Type == 'Voice') && check(A_Party).against('CC.NDC.NUMBER').basedOn(ctx.A.number) && check(Time_Stamp).after(testcase.startTime) && check(Time_Stamp).before(testcase.finishTime)" } } |
The definition in the example above states that tickets are selected according to the A-party's number in a specific format and a certain time window that starts with the time stamp after the test case has started and ends with the time stamp before is has finished. Since there is a double pipe ( ||
) that stands for "or", these tickets can be either of the type SMS or Voice.