Unable to define a VBScript Class in a function library

I have a VBScript class defined in a separate script that is associated with my test as a function library, but the class is not recognised.  According to the documentation

Your function libraries can contain:

  • Function definitions (function signature and code). You can call these functions from other functions, from actions in your test, or from your component. To call a function from a test or component, you must first associate the function library with the test or with the component's application area.

  • VBScript statements. These are statements that are not contained within function definitions (for example, RegisterUserFunc statements). UFT One runs all of these statements when it loads the function library.

So it would stand to reason that a class declaration inside a function library would be run so that I can create an instance of that class in my test code:

class CSlickGridDataRows

    private m_Rows

    private sub class_Initialize
        Set m_Rows = CreateObject("Scripting.Dictionary")
    end sub

    private sub class_Terminate
        Set m_Rows = Nothing
    end sub
    
    Public Property Get Item(sKey)
        Item = m_Rows(sKey)
    End Property
    
End Class

Creating an instance in my test code doesn't work (I get a run error "Class not defined: ''CSlickGridDataRows"):

Set o = new CSlickGridDataRows

If I include the class definition in the test code then it works fine, so it would appear that function libraries don't respect class definitions but just ignore them.

Could someone please confirm whether this is a bug in UFT One?  Or suggest a workaround? 

I'm using UFT One CE 24.2 under a concurrent company-wide license

Thanks in advance

Tags:

Parents Reply Children