Forum Discussion

amit_1's avatar
amit_1
New Contributor
13 years ago

How to add a Unit in Script using code?

Hi,



I was just wondering that is it possible to add a new Unit in my Script section in the Project Workspace with the help of coding.

I have gone through the 'Help File' of Test Complete. I have seen that it is possible to do it using Integration Object. But that requires a COM server. What if I don't have to use COM server. Is it possible to add the script without using COM server?

Any solution for this?



Thanks

2 Replies

  • Hi,


    You are right. You can add a new script unit to the project by using the ProjectIntegration.AddUnit method. This is the simplest way to do this.



    Another way is to create a custom plug-in that will create new program objects for working with the Script project item and expose these objects for using in scripts. For more information on creating custom plug-ins, see http://smartbear.com/support/viewarticle/11507/ in the online documentation.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Note, however, that this is still only if you're using TestComplete as COM.  If you're running scripts through TestComplete or TestExecute, you cannot add new units to the project real-time.



    Can I ask what you're trying to do?  Perhaps there's another way to achieve the same result.  In my experience, there isn't really a compelling reason to add a whole new unit of code to a project once it's running out side of the COM/Connected Application environment.