Ask a Question

Testcomplete does not update Routines list if function are available inside the Javascript Class.

SaravanaKumar_N
Contributor

Testcomplete does not update Routines list if function are available inside the Javascript Class.

Hi All,

 

I know I am looking way forward. But it would be good, if we have this option with TestComplete.

Since from ECMA6 - JavaScript we could use Class concepts, I thought of implementing this with our tool.

 

As shown in the sceenshot below, I have used javascript Class concepts, but the functions created inside the classes are not taken into the account of the Routines list at the top. 

Since we do not have intellisense to navigate to the functions from one unit to another unit, at least this option would be really helpful for easy navigation.

 

Also I would appreciate if someone could suggest any options to overcome this or intellisense issue.

 

TC_JavaScript_Classes.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thanks,

Saravana

7 REPLIES 7
HKosova
Moderator

Re: Testcomplete does not update Routines list if function are available inside the Javascript Class

Hi Saravana,

 

That combo box lists top-level functions only (those defined in the global context of a unit). You can submit an enhancement request here. There's also an existing feature request to add code completion for class methods.


Helen Kosova
SmartBear Documentation Team Lead
________________________
SaravanaKumar_N
Contributor

Re: Testcomplete does not update Routines list if function are available inside the Javascript Class

@HKosova

 

Thank you. I will add this in the new feature thread.

Just noticed that even prototype function (JavaScript Project) as well not populated under the Routines list. JScript project prototype functions are listed.

 

Regards,

Saravana

tristaanogre
Community Hero

Re: Testcomplete does not update Routines list if function are available inside the Javascript Class

Can you give an example of a prototype function in a JScript project that is showing in the drop down?  I just did the following:

 

function testme() {
    function blah() {
        Log.Message('blah');
    }
    this.me;
    this.who;
    this.whatever = function (){
        Log.Message('what');
    }
}

 And, as expected, only "testme" shows up in the drop down as that is a function that is declared globally on the unit.


Robert Martin
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available
SaravanaKumar_N
Contributor

Re: Testcomplete does not update Routines list if function are available inside the Javascript Class

@tristaanogre,

 

 

Sorry, I meant about the way I have shown in this picture.TC_JavaScript_JScript_RoutineList.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thanks,

Saravana

tristaanogre
Community Hero

Re: Testcomplete does not update Routines list if function are available inside the Javascript Class

Gotcha.  Yep, seeing that.

Now, @HKosova probably can give a more official response but, as I understand it, the routine drop down at the top of a script edit window is intended within the context of developing test cases as script. Each "routine" is, potentially, a test case and the idea is to give easy access to select such a test case and then click the "Run Current Routine" button.

 

While in a full JavaScript IDE, those methods are "routines", they are not test cases or methods that can be run in such a manner... you need to instantiate the object and then run the routine.  So, in the context of what TestComplete provides, this doesn't feel to me like it makes sense. That said, not sure why it works in JScript but not in JavaScript but, basically, that's how I experience it.  I look forward to seeing the feature request as there might be some cool aspects about it concerning turning TC into something more of a full IDE.

Now, to your question about intellisense, etc...  Creating classes and such and then having them available in what TC calls "code completion" would be cool.  But keep in mind that, effectively, each script unit is being treated in the same way that a page is treated when using JavaScript for web development.  You cannot call a routine or method or property of an object instantiated in a different web page unless you first import it into the web page or otherwise pass it through. So, in that line, TC is following that model.  If you want an object to be available in Code completion, that object needs to be built in, somehow, to the environment either as a plugin or a Script Extension.


Robert Martin
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available
SaravanaKumar_N
Contributor

Re: Testcomplete does not update Routines list if function are available inside the Javascript Class

@tristaanogre

 

Thank you for the valuable inputs.

I understood the routine list purpose. Then it would be good if we have something like tree structure of a Unit with its contents (like each functions) under Project Explorer as it would display in Eclipse IDE. Any solutions would be so helpful for us.

And yes, with JavaScript Class, I am able to export/import to another unit and can access its methods. Its working as expected.

Also these are core units files of the Project and we do not want to use as ScriptExtensions, since these are expected to change very often.

As you said Code completion is good with ScriptExtensions.

 

So as @HKosova, I will put this in Features section. Hope Smartbear admins can come up with smart solution.

 

Many Thanks,

Saravana

tristaanogre
Community Hero

Re: Testcomplete does not update Routines list if function are available inside the Javascript Class

If they are core units to a project, I wouldn't expect them to change that frequently... test cases that consume those units, yes... but the actual core units of a test framework should be relatively static. But then, that's just my way of designing things.. YMMV.

 

I keep my extension code in my TFS repository along with everything else so I can track it, develop it, version it, etc. The only difference between that code and my regular script code is that I need to "package" it as a tcx... but that takes all of 2 minutes... and if I am only changing my core code a few times a quarter, then adding 2 minutes to my work isn't that big of a deal. 🙂


Robert Martin
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: