研究DDE执行流程(脚本以ClassicsC_2001为例说明):
1. 打开测试脚本CycleDriverTest.rec
2. 找到CDCyleDriver函数,打开CycleDriver.SBL类库文件
3. 研究源代码。函数处理流程是打开.CDD文件,调用CycleDriver,SuietDriver,StepDriver处理相应测试数据文件(.CDD,.STD,.SDD),整个大循环 Do until …..loop读取.CDD文件,解析关键字,根据相应的关键字,调用SuiteDriver引擎。SuiteDriver解析关键字内容调用StepDriver引擎。StepDriver解析关键字后调用DriverCommand来处理。
一.我们以CDD文件中“T“命令来详细看一下代码的运行流程,主代码脚本调用CycleDriver.SBL中函数CDCyleDriver,读取CDD文件解析关键字遇到命令类型”T”,调用CDProcessTestRecord函数,函数调用SuiteDriver引擎处理。下面是CDCyleDriver核心代码:
Sub CDCycleDriver (filename As String, separator As String, _
fac As LogFacility, suiteFac As LogFacility, stepFac As LogFacility, _
Optional mode)
XXXXXXX
读取文件
Do Until EOF(Fileref)
解析数据文件,调用相应的命令
Select Case RecordType
Case DDU_DRIVER_COMMAND, DDU_DRIVER_COMMAND_FAILOK, DDU_DRIVER_COMMAND_WARNOK
Result = DDEDriverCommand (CycleDriverGUIInfo, CycleDriverInfo)
Case DDU_SKIP_TEST_STEP
Result = DDESkippedRecord(CycleDriverGUIInfo, CycleDriverInfo)
Case DDU_TEST_STEP, DDU_TEST_STEP_FAILOK, DDU_TEST_STEP_WARNOK
PushSuiteDriverSTACK
Result = CDProcessTestRecord(suiteFac, stepFac)
if Result = CDNoScriptFailure then AUSumStatusInfo SuiteDriverTestInfo, CycleDriverTestInfo
PopSuiteDriverSTACK
Case DDU_BLOCKID
Result = DDEProcessBlockID(CycleDriverGUIInfo, CycleDriverInfo)
Case DDU_BREAKPOINT
if DDU_BREAKPOINTS_ENABLED then
DDU_BREAKPOINTS_MODE = 1
LogMessage "Breakpoint at line "& Str$(CycleDriverInfo.linecount) &" in "& filename, fac
end if
Goto MainLoop
'IMPLIED Script executed or UNKNOWN RECORD TYPE logged
Case Else
Result = DDEImpliedCallScript (RecordType, CycleDriverGUIInfo, CycleDriverInfo)
End Select
XXXXX
Loop
XXXX
END Sub
总结:调用过程 CDCycleDriver---〉CDProcessTestRecord—〉STSuiteDriver
二.处理High-level中命令类型“T”
例如:T, AddUserAccount,, ^user=Name
1)打开SuiteDriver.SBL
2)定位到函数STSuiteDriver处理记录类型的代码,,下面是STSuiteDriver 函数代码判断,当Record类型为“T”,他调用Case DDU_TEST_STEP, DDU_TEST_STEP_FAILOK, DDU_TEST_STEP_WARNOK后边的代码:
Select Case RecordType
Case DDU_DRIVER_COMMAND, DDU_DRIVER_COMMAND_FAILOK, DDU_DRIVER_COMMAND_WARNOK
Result = DDEDriverCommand (SuiteDriverGUIInfo, SuiteDriverInfo)
Case DDU_SKIP_TEST_STEP
Result = DDESkippedRecord(SuiteDriverGUIInfo, SuiteDriverInfo)
Case DDU_TEST_STEP, DDU_TEST_STEP_FAILOK, DDU_TEST_STEP_WARNOK
PushStepDriverSTACK
Result = STProcessTestRecord(stepFac)
if Result = STNoScriptFailure then AUSumStatusInfo StepDriverInfo, SuiteDriverTestInfo
PopStepDriverSTACK
Case DDU_BLOCKID
Result = DDEProcessBlockID(SuiteDriverGUIInfo, SuiteDriverInfo)
Case DDU_BREAKPOINT
if DDU_BREAKPOINTS_ENABLED then
DDU_BREAKPOINTS_MODE = 1
LogMessage "Breakpoint at line "& Str$(SuiteDriverInfo.linecount) &" in "& filename, fac
end if
Goto MainLoop
'IMPLIED Script executed or UNKNOWN RECORD TYPE logged
Case Else
Result = DDEImpliedCallScript (RecordType, SuiteDriverGUIInfo, SuiteDriverInfo)
End Select
3)调用StepDriver引擎处理命令
总结:调用过程STSuiteDriver ---〉STProcessTestRecord—〉SDStepDriver