ivan_sy
12 years agoContributor
GeneralEvents calls a script that calls some other scripts -- result to type mismatch
I have the following two scripts:
SCRIPT_Project_Events
SCRIPT_Project_Settings
The problem:
I configured OnStart and OnStop General events that in any situation the Options.Run.Timeout will always use the value specified in a variable.
The design of our project is to allow some scripts to change the Options.Run.Timeout to a lower value temporarily. The problem I noticed is that whenever there is any interruption (user interruption) during that specific time that the script was running, the TestComplete project settings retains that lower value and losses it pre-configured value. Anyways...
Both OnStartTest and OnStopTest uses a file SCRIPT_Project_Events
in SCRIPT_Project_Events:
'USEINIT SCRIPT_Project_Settings
Sub GeneralEvents_OnStartTest(Sender)
Set_TestProject_Settings()
' I plan to call more functions in some other scripts
End Sub
Sub GeneralEvents_OnStopTest(Sender)
Set_TestProject_Settings()
' I plan to call more functions in some other scripts
End Sub
and on the other file, SCRIPT_Project_Settings:
Sub Set_TestProject_Settings()
If (Options.Run.Timeout < Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE) Then
Options.Run.Timeout = Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE
End If
End Sub
The above design results to a VBScript runtime error:
Type mismatch: 'Set_TestProject_Settings'
-------------------------------
However, if i took that piece of code out...
making SCRIPT_Project_Events as :
Sub GeneralEvents_OnStartTest(Sender)
If (Options.Run.Timeout < Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE) Then
Options.Run.Timeout = Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE
End If
End Sub
Sub GeneralEvents_OnStopTest(Sender)
If (Options.Run.Timeout < Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE) Then
Options.Run.Timeout = Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE
End If
End Sub
Then the design works.
I'd like the first design as I may have (some time soon) more scripts to add up to OnStartTest and OnStopTest Event.
I don't want that the GeneralEvents_OnStartTest will get cluttered with codes.
Is that this an option? What's causing the type mismatch?
SCRIPT_Project_Events
SCRIPT_Project_Settings
The problem:
I configured OnStart and OnStop General events that in any situation the Options.Run.Timeout will always use the value specified in a variable.
The design of our project is to allow some scripts to change the Options.Run.Timeout to a lower value temporarily. The problem I noticed is that whenever there is any interruption (user interruption) during that specific time that the script was running, the TestComplete project settings retains that lower value and losses it pre-configured value. Anyways...
Both OnStartTest and OnStopTest uses a file SCRIPT_Project_Events
in SCRIPT_Project_Events:
'USEINIT SCRIPT_Project_Settings
Sub GeneralEvents_OnStartTest(Sender)
Set_TestProject_Settings()
' I plan to call more functions in some other scripts
End Sub
Sub GeneralEvents_OnStopTest(Sender)
Set_TestProject_Settings()
' I plan to call more functions in some other scripts
End Sub
and on the other file, SCRIPT_Project_Settings:
Sub Set_TestProject_Settings()
If (Options.Run.Timeout < Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE) Then
Options.Run.Timeout = Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE
End If
End Sub
The above design results to a VBScript runtime error:
Type mismatch: 'Set_TestProject_Settings'
-------------------------------
However, if i took that piece of code out...
making SCRIPT_Project_Events as :
Sub GeneralEvents_OnStartTest(Sender)
If (Options.Run.Timeout < Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE) Then
Options.Run.Timeout = Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE
End If
End Sub
Sub GeneralEvents_OnStopTest(Sender)
If (Options.Run.Timeout < Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE) Then
Options.Run.Timeout = Project.Variables.OPTIONS_RUN_TIMEOUT_VALUE
End If
End Sub
Then the design works.
I'd like the first design as I may have (some time soon) more scripts to add up to OnStartTest and OnStopTest Event.
I don't want that the GeneralEvents_OnStartTest will get cluttered with codes.
Is that this an option? What's causing the type mismatch?
Hi Ivan,
There is a misprint in the USEUNIT statement. You wrote USE--I--NIT.
As a result, TestComplete doesn't see the SCRIPT_Project_Settings script unit.