I'm using a Class statement (follows at end) that i'd like to locate outside of the main test, in order to reuse it easier.
If i include the entire statement in the main action, it works fine.
If i do any of the following, i get "class undefined" error when trying to create an instance of it (via: Set shopper = new User):
1. create a new test called "Classes". Create a reusable action in it called
"UserClass", which contains the Class statement. Call it either via "include call to external action" or "insert copy of existing action".
2. create function library called UserClass.qfl.
Include the Class statement in this qfl, surrounded by:
Sub makeUserClass()
[Class statement]
End Sub
I associate the qfl with the test, then call makeUserClass() before creating new instance.
3. save Class statement variously as UserClass.qfl, UserClass.vbs, User.class. variously use: executeFile; executeGlobal (on a string containing the code).
any help on how to clean this up appreciated.
mike
(QTP 9.2)
If i include the entire statement in the main action, it works fine.
If i do any of the following, i get "class undefined" error when trying to create an instance of it (via: Set shopper = new User):
1. create a new test called "Classes". Create a reusable action in it called
"UserClass", which contains the Class statement. Call it either via "include call to external action" or "insert copy of existing action".
2. create function library called UserClass.qfl.
Include the Class statement in this qfl, surrounded by:
Sub makeUserClass()
[Class statement]
End Sub
I associate the qfl with the test, then call makeUserClass() before creating new instance.
3. save Class statement variously as UserClass.qfl, UserClass.vbs, User.class. variously use: executeFile; executeGlobal (on a string containing the code).
Code:
Class User
dim email,_
fname,_
lname,_
....etc
Sub Class_Initialize()
email = "qa" & MonthName(Month(Now)) &_
Day(Now) & Year(Now) & Hour(Now) &_
Minute(Now)& Second(Now) & "@mydomain.com"
fname = RandomWord(3,10)
lname = RandomWord(3,10)
....etc
end sub
Sub saveUser()
DataTable.Value("email", "Global") = email
DataTable.Value("fname", "Global") = fname
DataTable.Value("lname", "Global") = lname
....etc
end sub
End Class
any help on how to clean this up appreciated.
mike
(QTP 9.2)