Forum Discussion

TestQA1's avatar
TestQA1
Frequent Contributor
4 years ago
Solved

Calling JavaScript routines in TestComplete

Hi Folks,

I have been trying to use //[Commonunit] and //[MainUnit] to use one unit into another but it's not working.

Let's say i have one unit called A and another called B. I'm trying to pass call constructor from B.

A:
//[A]
var u, p;
function A(u,p){
this.u = u;
this.p = p;
}
module.exports.A()=A;

B:
//[B]
var c = require(A);
c.A("abc","xyz");

I don't know how to use commonunit and mainunit at the beginning.

Also, I'm using BDD cucumber and want to adopt modularity in my scripts but gherkin supplies parameters in it's when, then statements in feature file. Is there a way I can use variable instead of values in gherkin feature file and supply data from some other unit such as from executing constructor etc. like in oop.

Thanks
  • TestQA1's avatar
    TestQA1
    4 years ago

    Great! thanks, works fine.

     

    I'm trying to make my scripts to be able to some OOP things, would that be possible?

     

     

2 Replies

  • ApplePen's avatar
    ApplePen
    Community Leader

    Please try it below capture.

     

    About gherkin, I haven't done it before. Sorry, I can't help you.

    • TestQA1's avatar
      TestQA1
      Frequent Contributor

      Great! thanks, works fine.

       

      I'm trying to make my scripts to be able to some OOP things, would that be possible?