Forum Discussion

ecrespo's avatar
ecrespo
Occasional Contributor
12 years ago

COM API testing - No GUI - .NET

I would like to test a COM API without GUI using TestComplete, is this possible?

All the objects needed to test the Windows application are contained in a .tlb file, which is registered when the Application is installed in the system.



I was looking into using external DLLs, but it seems rather cumbersome in this case if I have to redefine/register all the new custom types (structures) to use TestComplete.



Originally, some of the testing was done by writing exel macros in VBA and once the library was loaded into the references, the program could be launched simply as:



Set SCApp = New (MyLibraryName).Application



Then all the Application objects, properties, and  methods were accessible. For example, to create a point with coordinates xcoor, ycoor, zcoord



Dim  SCModel as (MyLibraryName).Model

Dim xcoor As Variant, ycoor As Variant, zcoor As Variant

Set SCModel = SCApp.Document.Model

...

SCModel.Points.AddAutoGlobal xcoor, ycoor, zcoor

2 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Eva,



    If the COM server is registered in the system it can be instantiated and operated by TestComplete (i.e. tested). As the COM does not have UI, such testing can be done even unattended, when no user is logged on into the system.



    An example of working with COM objects (using Excel) can be found in the <Users>\Public\Documents\TestComplete 9 Samples\Miscellaneous\MSOffice\ folder (select the script language you prefer and open the MSOffice.pjs test project from the relevant folder).
  • I am doing just this right now on one of my projects. If you registered it correctly to windows you should be able to access it without any problems. 



    *example of how to :  (jscript because that's what I use) 

    var Obj = Sys.OleObject("ObjectYouWantToUse");





    then you can just Access methods and properties like you would with anything else. 

    var ObjMethod = Obj.MethodName