There are two variations of test scripts:
A script test script belongs to a so-called tested script, which can be anyone of the scripts explained in the previous sections. A script test script is used to test the correctness of the tested script it belongs to. It does this by calling the tested script with different input conditions and checking the results for each call. If a result is different from the expected result, a test fail error is created and appended to a list of all encountered test fails.
A RSE test script belongs to a RSE (type, factory or service) and is used to test the correct functioning of the RSE. It does this by using any features (attributes, commands and events) and comparing the real results with expected results. If a result doesn't match the expected result, a test fail error is created and appended to a list of all encountered test fails.
Table 7.16. Attribute default script selector
| Production | Syntax | Links |
|---|---|---|
test_script_selector | the section called “test script” | |
script_test_script_selector | RSE_script_selector "." "co_test_" | |
RSE_test_script_selector | RSE_selector "." "co_test_" |
This script has one input argument that holds the list of all test fails encountered. This input argument's id is i_test_fail_list_ and its type is ty_test_fail_list. Each time a test fails, an object describing the test fail is automatically appended to i_test_fail_list_.
Test fails are implicitly generated with the verify and verify error instruction, whenever the expected result differs from the real result.
If the test script is a script test script (and not a RSE test script) then the following variables are implicitly created by the compiler:
For each output argument defined in the tested script, a corresponding variable is defined in the test script. The id suffix and type of these variables are the same as those of their corresponding output arguments. Each time a test instruction is executed, all output arguments are implicitly stored in their respective variables. The verify instruction can then use these variables to verify the result(s) of the tested script.
If the test script belongs to a factory, then variable v_test_object_ is implicitly defined. The type of this variable is the same as the type implemented by the factory (e.g. if factory book implements type book, then variable test_object_ is of type book).
At the beginning of the test script an object must be assigned to v_test_object_. This object is then used by each subsequent test instruction.
Example 7.3. A simple test script example
service script_examples
command double_string
in string type:string end
out result type:string end
script
o_result = i_string & i_string // simply return twice the input string
end
test // start of test script
script
test "a" // call co_double_string with i_string = "a"
verify v_result =v "aa" // verify result is "aa"
test "foo"
verify result =v "foofoo"
var string test_string = void
test test_string // will produce an input argument check error,
// because i_string cannot be void
verify error // verify an error occured indeed
end script
end test
end command
endThe above test script can manually be executed like this:
var test_fail_list test_fail_list = fa_test_fail_list.co_create se_script_examples.co_test_ ( v_test_fail_list ) v_test_fail_list.display_result // display test result on system console
For other examples, see: