cancel
Showing results for 
Search instead for 
Did you mean: 

find unused script routines

SOLVED
Super Contributor

find unused script routines

Is there an easy way to find all script routines that are not called anywhere, by other scripts or by keyword tests? Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: find unused script routines

Hi Guys,

 

The Finding Usages article says that:

TestComplete does not support searching for usages in script units associated with other units through adding the module.exports object.!


So, the behavior you see is expected.

As an alternative, you can find occurrence via the Search/Replace dialog.

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
16 REPLIES 16
Community Hero

Re: find unused script routines

If you're using TestComplete 12.60, you should be able to right click on the routine and select "Find Usages".  That will then return all script references and Keyword test references to that script routine.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Super Contributor

Re: find unused script routines

That does not appear to work consistently. For instance, I have a function called GetRandomString(). It is called many times across various script functions. When I do find instances for that function, my search results show no results.

 

Is there something I need to do that I am missing? Thanks

Community Hero

Re: find unused script routines

I wonder if it might have to do with the implementation.  How are you using that script in other locations?  Are you using \\USEUNIT or are you using the native JavaScript "import"?


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Super Contributor

Re: find unused script routines

In the unit that the called function is present

 

module.exports.GetRandomString = GetRandomString;

 

in the calling unit(s)

 

var CommonUtilities = require("CommonUtilities");

 

This is what the Import dialog in TestComplete does. I THINK I saw somewhere that Useunit was being depricated.

 

Thanks.

Community Hero

Re: find unused script routines

Not deprecated, just that it's not necessary for JavaScript.

However, that MIGHT be what's going on.  Because you're using the native JavaScript engine method for importing routines, the algorithm that does the "Find Usages" might not be finding it.  That MIGHT be something that needs to be brought to the attention of the customer service staff.

As a test, what happens if you use the \\USEUNIT to include your library containing GetRandomString() and then try it.  Does it work then?

 


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Super Contributor

Re: find unused script routines

I replaced require... with //USEUNIT in one of my calling procs. No love.

Community Hero

Re: find unused script routines

Is that function a method on an object?  Or is it a stand along function within a unit?


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Super Contributor

Re: find unused script routines

A standalone function within a unit.

Super Contributor

Re: find unused script routines

Ya know, it IS a feature exposed in TestComplete. I'm going to create a support ticket. Thanks for your help.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors