Studio:Initialize.pm

From STRIDE Wiki
(Redirected from Initialize.pm)
Jump to navigation Jump to search

This package provides a simple procedural interface that simplifies the STRIDE initialization logic required for scripts that execute outside of the STRIDE Studio environment.

Example

use strict;
use Win32::TieRegistry(Delimiter=>"/");
use File::Spec;
use Win32::OLE;
Win32::OLE->Option(Warn => 3);
   
use vars qw($StrideDirectory $StrideLibDirectory);
   
BEGIN {
    $StrideDirectory = $Registry->{"LMachine/SOFTWARE/S2 Technologies/STRIDE/InstallDir"};
    $StrideLibDirectory = File::Spec->catdir($StrideDirectory, 'lib', 'perl');  
}
use lib $StrideLibDirectory;
use S2S::Initialize qw(Init MakeReport);
    
Init(database => '../my.sidb', autoConnect => 1);
# your code here
MakeReport('myResult.html');

Functions

The following functions are all exported on request only (EXPORT_OK).

Init (database => 'path', autoConnect => 1)
When a script is executed outside of the STRIDE Studio context, this function creates and/or initializes several objects in the main namspace: ascript, reporter, testSuite, and transport. If any of these objects already exist, they will be overwritten by Init. If the autoConnect option is true, then this method will also initiate a target connection. When the calling script is being executed in the Studio context, the initialization of the variables in main is skipped, but the autoConnect flag is still honored. This function returns 1 when the global objects have been set (when running outside of Studio's context) and 0 otherwise.
Connect ([timeout])
If not already connected, this initiates a connection to the target. An optional timeout (in seconds) argument can be given which specifies how long to wait for the connection to be established (default is 5 seconds). The Target connection parameters are specified in the [STRIDE_DIR]\bin\transport.cfg configuration file. The default values need to be adjusted to the test environment. Refer to the Transport Configuration File page for more details.
Disconnect
Disconnects the target connection if current connected.
MakeReport('path')
This causes the current reporter data to be written to the file specified in 'path'. If the provided file is a relative path, it is assumed to be relative to the location of he currently executing script.
Publish('uploadPath', 'name', 'configPath')
This uploads test results to a STRIDE Test Spaces server. If the optional 'uploadFile' is specified, it is the upload source, otherwise the reporter object results are uploaded. If the optional 'name' parameter exists, it is used to name the results set, otherwise a name will be created based on date/time. The default parameters in test_space.cfg (in the bin directory of your STRIDE installation) are used for uploading unless a 'configPath' file is provided.