Tekvel Magic
|
Test scenario controller singleton class. More...
Public Member Functions | |
def | __init__ (self, test_result_id=None) |
def | get_system_info (self) |
Returns system info. More... | |
def | get_application_info (self) |
Returns application info. More... | |
def | get_test_environment (self) |
Returns test environment info including application info and system info. More... | |
def | log_test_environment (self) |
Writes full test environment data to the test log. More... | |
def | log (self, str text) |
Writes a message to the log. More... | |
def | bulk_log (self, list log_list) |
Writes a list of messages to the log. More... | |
def | log_validation_errors (self, scl_validation_result) |
Writes SclValidationResult errors to log. More... | |
def | log_result_messages (self, TestResult test_result) |
Writes messages from TestResult objects to the log. More... | |
def | log_result_errors (self, test_result) |
Writes errors from TestResult objects to the log. More... | |
def | set_result (self, result, str text="") |
Sets overall test result. More... | |
bool | result_not_set (self) |
Shows if the test result has already been set. More... | |
def | get_artifact (self, str artifact_id) |
Retreives artifact associated with running test case. More... | |
def | save_artifact (self, artifact_id, save_path) |
Saves artifact with specified artifact_id to the file specified by file_path. More... | |
def | save_file (self, bytes binary_data, str save_path) |
Saves binary data to the file specified by file_path. More... | |
Test scenario controller singleton class.
This class provides interaction with Magic's test engine. Particularly this class provides loggin of test environment data, loogging of messages, setting the results of the test, etc. The class is initialized with the same name inside the test scenario context and requires no additional initialization.
def __init__ | ( | self, | |
test_result_id = None |
|||
) |
def bulk_log | ( | self, | |
list | log_list | ||
) |
Writes a list of messages to the log.
log_list | List of strings to be written to the log |
Function is used to write a list of messages to the log.
This function is highly recommended for use with list of multiple messages insted of writing log messages inside a loop with log() function as it offers much higher performance. For logging only one message you can still use log() function.
def get_application_info | ( | self | ) |
Returns application info.
def get_artifact | ( | self, | |
str | artifact_id | ||
) |
Retreives artifact associated with running test case.
artifact_id | artifact identifier within the scope of the test. |
artifact_id
parameterArtifacts are typically huge parts of string-type data associated with the test. Typically artifacts are used to store SCL-files assiciated with specific tests, which allows not to have them directly described as string inside the test scenario as well as to ship them together with test procedures without the need to deal with filesystem referemces, etc. Artifacts can also be used to store string-type test report tempates, huge regular expressions, etc.
The artifact_id parameter shall be unique within the scope of specific test. When returned the artifact can either be used direcly or used as an input to other API-functions.
def get_system_info | ( | self | ) |
Returns system info.
def get_test_environment | ( | self | ) |
Returns test environment info including application info and system info.
United data collected by get_system_info() and get_application_info() into single dict for convinient use.
def log | ( | self, | |
str | text | ||
) |
Writes a message to the log.
text | Text message to be written to the log |
Function is used to write single message to the log.
Note that is not recommended to write multiple messages in a loop using this function. If there is a list of messages to be logged, use bulk_log() function instead.
text |
def log_result_errors | ( | self, | |
test_result | |||
) |
Writes errors from TestResult objects to the log.
test_result | TestResult instance, containing test errors |
The function is used to write all test errors from TestResult class object to the log.
def log_result_messages | ( | self, | |
TestResult | test_result | ||
) |
Writes messages from TestResult objects to the log.
test_result | TestResult instance, containing test log messages |
The function is used to write all test log messages from TestResult class object to the log.
def log_test_environment | ( | self | ) |
Writes full test environment data to the test log.
The function calls get_test_environment() function to retreive test environment information and then logs it test log. The function requires no additional parameters.
def log_validation_errors | ( | self, | |
scl_validation_result | |||
) |
Writes SclValidationResult errors to log.
scl_validation_result | SclValidationResult instance, containing validation errors |
The function is used to write all validation errors from SclValidationResult class object to the log. Example usage is shown below
The function uses bulk_log() function to log multiple messages, so it would provide good performance even if there are thousands of validation erros.
bool result_not_set | ( | self | ) |
Shows if the test result has already been set.
This function can be used to avoide multiple test result setting inside long test scenarios with multiple set_result() functions. Thus eash set_result() call shall be preceded with the check that test result has not been set previosly. See code snippet below.
def save_artifact | ( | self, | |
artifact_id, | |||
save_path | |||
) |
Saves artifact with specified artifact_id to the file specified by file_path.
artifact_id | artifact identifier within the scope of the test. |
save_path | filepath (incliding filename) where the specified artifact shall be saved. |
The function can be used to save SCL-files associated with specific test case. The function is particularly usefull when some reference files have to be exported from the test procedure.
Use Dialog class funtions to provide user with dialog-windows to select location to store files.
def save_file | ( | self, | |
bytes | binary_data, | ||
str | save_path | ||
) |
Saves binary data to the file specified by file_path.
binary_data | binary data to be written to file. |
save_path | filepath (incliding filename) where the specified data shall be saved. |
The function can be used to save binary data obtained during the test.
For string-type data use encoding to obtain the binary representation of the data, eg.
Use Dialog class funtions to provide user with dialog-windows to select location to store files.
def set_result | ( | self, | |
result, | |||
str | text = "" |
||
) |
Sets overall test result.
The function sets the test result and displays a dialog message with text
. Typically, this function should be called at the very end of the test script. Avoid using this function multiple times in the code to prevent confusion from multiple settings of the result. Example usage is shown below.
result | Integer representation of the result as described by Result class. |
text | The message to be displayed in the dialog. |
None |