Forum Discussion

sbkeenan's avatar
sbkeenan
Frequent Contributor
13 years ago

Adding and Removing References

Hi



When working on a new test case, I usually create a Globals project within the project suite that I use to hold a name mapping unit and one or more class files.  My other projects contain their own name mapping units that I merge with the one held in Globals and I use the USEUNIT line at the top of any scripts that I need to reference the class files and also add the class files to the project(s) in question by right-clicking on the Script unit and using the Add Existing Item option.



All of the above works well and I have no problems with its use, however, the particular test case I am working on will require access to many different class files, both from within the existing project suite and from within other project suites.  Again, I have no problems with making this all work, but I do have one problem.  If I create a reference to a class file that subsequently is not required, how do I remove it?  If I right-click on it and select Remove then Delete, TestComplete will actually delete the original file from its original location, meaning that every other reference in every other script file that references it will be broken.  Could it be a suggestion that this kind of removal/deletion on a reference item simply removes the reference link, leaving the original file intact?  I guess that simply selecting Remove  from the right-click menu is the answer to this question at present, but if the Delete option is accidentally selected, it's pretty catistrophic if there is no backup available!!



I've also looked at the Add Unit References option, but this only seems to work if there is more than one reference, i.e. if a script references more than one other unit, I can remove the ticks against the ones I don't require and click on OK, however, in my case the other units are themselves references to other class files and I don't want to have any of their code modified.  If I remove all the ticks, I cannot click on OK.  Is there something that I am overlooking?



Finally, could I make a suggestion that the referenced items in the project tree have a different icon, something to show that they are references to other units, perhaps something like the Windows shortcut icon, where a little arrow appears in the bottom left corner.  This would make it visually clear that a particular item is a reference to an original in another location.



Many thanks.



Regards

Stephen.

1 Reply

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Stephen,


    if the Delete option is accidentally selected


    The default selected button in this message box is "Remove". So, if you click "Delete", we suppose that you do this intentionally. Anyhow, I agree with your words that the consequences can be "catastrophic". I spoke with the developers and we'll think how to improve the situation.


    could I make a suggestion that the referenced items in the project tree have a different icon, something to show that they are references to other units, perhaps something like the Windows shortcut icon, where a little arrow appears in the bottom left corner.


    From TestComplete's point of view, there is no "referenced" and "non-referenced" files as both files reside on the hard drive and the project just stores the path to them. I added your request to our database. We'll think what we can do. Most likely, we will "highlight" project items that reside out of the project's folder.


    If I create a reference to a class file that subsequently is not required, how do I remove it?


    I'd suggest the following procedure:

    * Right-click the unit in the Project Explorer and choose Remove from the context menu.

    * TestComplete will display a dialog suggesting you to remove or delete the unit. Click Remove.

    * Right-click the Script node in the Project Explorer and select Check Syntax from the context menu. The syntax check will fail in the unit that refers to the unit you removed. So, you can delete the appropriate //USEUNIT statement from it.

    * Click Check Syntax from the Script node's context menu again. TestComplete will find another unit that refers to the removed unit.

    * Repeat these steps until you clear all the references.