Studio:Initialize.pm: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
 
This package provides a simple procedural interface that simplifies the STRIDE initialization logic required for scripts that execute outside of the [[STRIDE Studio]] environment.
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 ==
== Example ==

Revision as of 18:01, 12 February 2009

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.