Hello,
the main test script looks like this:
#global variables
public g_sGuifolder;
public g_sConfigfile;
public g_sSysdate;
public g_sSearchpath;
public g_sLogging;
#constants
public const cLevelTA = 200;
public const cLevelTC = 100;
public const UNKNOWN_CONTROLTYP = -9999;
rc = E_OK;
#set the enviromentvariables
g_sSearchpath = "C:\\Testrun\\";
g_sConfigfile = g_sSearchpath & "config.ini";
#Load required Libraries
rc = reload(g_sSearchpath & "Libs\\File", 0, 1);
rc = reload(g_sSearchpath & "Libs\\Util", 0, 1);
rc = reload(g_sSearchpath & "Libs\\Test", 0, 1);
rc = reload(g_sSearchpath & "Libs\\SpecialTAs", 0, 1);
#Unload and close all open and loaded Guimaps
if (rc == E_OK) {
rc = GUI_close_all();
rc = GUI_unload_all();
}
#read configfile
rc = getConfigValue(g_sConfigfile, "Executionfolder", g_sExecfolder);
rc = getConfigValue(g_sConfigfile, "Guimaps", g_sGuifolder);
rc = getConfigValue(g_sConfigfile, "Log", g_sLogging);
rc = set_window(Main);
if(rc!=E_OK)
startApplication();
g_sSysdate = getSysDate(); #implement function in "Util"
# write log headline
writeLog("<TestfallName>--<Datum>--<Control>--<Status>--<eventueller Fehler>");
#open the application in intial state
rc = startApplication(); #implement function in "Test"
#process the Testset
if (rc==E_OK)
{
rc = doTestSet();
}
#clear global variables
g_sGuifolder = "";
g_sConfigfile = "";
g_sSysdate = "";
g_sSearchpath = "";
g_sLogging = "";
#unload loaded Libraries
rc = unload(g_sSearchpath & "Libs\\File");
rc = unload(g_sSearchpath & "Libs\\Util");
rc = unload(g_sSearchpath & "Libs\\Test");
rc = unload(g_sSearchpath & "Libs\\SpecialTAs");
and the Testscript where the lines of the input file are read in and the commands (switch statement) are executed looks like this:
#declared in Testrun
extern g_sSearchpath;
extern g_sConfigfile;
extern g_sGuifolder;
extern g_sLogging;
extern g_sSysdate;
extern termination;
static tl_msg;
#function processes the testset
public function doTestSet()
{
auto sInputValues[];
auto rc = E_OK;
#start logging if global variable is true
if (g_sLogging==TRUE)
{
rc = logClear();
rc = logString("Starting Testset at " & g_sSysdate & "...");
if (rc!=E_OK)
pause ("ERROR: Could not write to 'Testlog.txt'");
}
#get rows from Input.csv
rc = getInputValues(g_sSearchpath & "\Input.csv", sInputValues);
if (rc!=E_OK)
logString(" ERROR: Couldn't read Testset in '" & g_sSearchpath & "\Input.csv'");
else
{
#loop through all TestCases and execute them
rc = executeTestCases(sInputValues);
if (g_sLogging==TRUE)
{
rc = logString("Testset finished at " & getTime());
if (rc!=E_OK)
pause ("ERROR: Could not write to 'Testlog.txt'");
}
if (rc!=E_OK)
pause ("ERROR: Could not execute Testset");
}
}
public function executeTestCases(inout sInputValues[])
{
auto rc = E_OK;
auto sTemp[];
auto sTC;
auto sControlName;
auto sControlTyp;
auto sActionTyp;
auto sWindow;
auto sArgument;
auto sState;
auto sFunction;
auto sLevel;
auto i = 0;
do
{
#ignore comments
if (substr(sInputValues
,1,1)=="#")
{}
else
{
# get the TestCase Name
if (match(sInputValues, "\[*\]"))
{
sLevel = cLevelTC;
sTC = substr(sInputValues, 2, length(sInputValues)-2);
if (g_sLogging==TRUE)
rc = logString(" processing TA: '" & sTC & "' at " & getTime());
}
#get TestAction Values
else
{
sLevel = cLevelTA;
split(sInputValues,sTemp, ";");
sWindow = sTemp[1];
sControlName = sTemp[2];
sControlTyp= sTemp[3];
sArgument = sTemp[4];
sActionTyp = sTemp[5];
#load Guimap and set window according to sWindow;
rc = GUI_open(g_sGuifolder & sWindow & ".gui");
rc = GUI_load(g_sGuifolder & sWindow & ".gui");
rc = set_window(sWindow);
#case of speacial treatment of Testaction call appropriate function
if (match(sInputValues, "SPTA_*")==1)
{
rc = eval(sInputValues & "();");
}
else
{
#process Control
if (g_sLogging==TRUE)
rc = logString(" performing '" & sControlName & "' with Controltyp '" & sControlTyp & "'" );
switch (sControlTyp)
{
case "list":
if(sActionTyp=="listSelect")
{
rc = list_select_item (sControlName,sArgument);
}
if(sActionTyp=="listActivate")
{
rc = list_activate_item (sControlName,sArgument);
}
break;
case "toolBar":
rc = toolbar_button_press("ToolbarWindow32", sControlName);
break;
case "textField":
rc = edit_set(sControlName, sArgument);
break;
case "Button":
rc = button_press(sControlName);
break;
case "menuItem":
rc = menu_select_item (sArgument";" & sControlName);
break;
default:
rc = UNKNOWN_CONTROLTYP;
pause("Unknown Controltyp");
}
tl_step(termination,1, tl_msg);
}
#wait 1,5 sec to handle next Control
wait(1,5);
rc = GUI_unload_all();
rc = GUI_close_all();
}
}
i++;
}
while(sInputValues!="");
}
#Starts the application so that the testcases can be executetd
public function startApplication()
{
auto rc = E_OK;
auto buttonText;
auto buttonInfo;
#start the application
invoke_application("","","", SW_SHOW);
return rc;
#A Crash Events in the Recovery Manager was defined for the case
#if the application crashes.
}
The problems which can occur in the test is that a window pops up with an notification or an error message.In that case I should be able to decide between a made screenshot and continue with the next testcase and a made screenshot and the whole test will be terminated.
The input file looks like this:
#Window;ControlName;ControlTyp;Argument;ActionTyp(optional)
[TC 1]
Main;Open;menuItem;File;menuItemSelect
OpenArchive;Search in:_0;list;Harddisk (C
;listSelect
Main;MakeExe;menuItem;Actions;menuItemSelect
[TC2]
TestNotification;Nein;Button;buttonPress
WinZipSelfExtractor;Close;Button;buttonPress
Main;CloseArchive;menuItem;File;menuItemSelect
Main;Exit;menuItem;File;menuItemSelect
I hope now you have a better overview about my problem...?
mathon