Forum Discussion

lui's avatar
13 years ago

Fails to create a Runtime Object using Script extension

I would like to create a runtime object, XXX,  using TC script extension.  My intend is to surface the XXX object which has two methods (beginTest() and endTest()), the script has an Initialize() function to instantiate the XXX object.    The two files for the extension are appended below.



I install my script via Script Extension Options, I was able to see my Runtime object in the Install Script Extensions dialog.  When I try to access the object via Code Completion ... window, I cannot not see it.



Any idea ?  Thank you.



Alex.





The Description xml file is:

---------------------------------



        <?xml version="1.0" encoding="UTF-8" ?> 

        <ScriptExtensionGroup Name="XXX Service Object">

         <ScriptExtension Name="XXX Service Object" Version="1.0" 

                Author="ABC"  HomePage="www.xxx.com">

  <Script Name="QngCommonService.js" InitRoutine="Initialize">

   <RunTimeObject  Name="XXX" >

    <DESCRIPTION>Provide QNG common services</DESCRIPTION>

   <Method   Name="beginTest"   Routine="beginTest">

    This service is to init setup before test

   </Method>

   <Method   Name="endTest"   Routine="endTest">

    This service is to clean up after test

   </Method>

   </RunTimeObject>

  </Script>

  <Description>Provides QNG Service Object.</Description>

 </ScriptExtension>

</ScriptExtensionGroup>        

        





The script "QngCommonService.js" file is:

---------------------------------------------------

var XXX = {};


function QngCommonService()

{

 

 var beginTest = function() {

  Log.Message( "---> beginTest()" );

 }

 var endTest = function() {

  Log.Message( "---> endTest()" );

 }


}


function Initialize(){

  Log.Message("---> Initialize()");

  XXX = new QngCommonService();

}



  • Hi Alex,


    Your script extension is designed incorrectly. Please review our Creating Runtime Objects Tutorial and correct it. Here is the example of how it might look like:



    <?xml version="1.0" encoding="UTF-8" ?>

    <ScriptExtensionGroup Name="XXX Service Object">

      <Category Name="Runtime Objects">

        <ScriptExtension Name="XXX Service Object" Version="1.0" Author="ABC" HomePage="www.xxx.com">

          <Script Name="QngCommonService.js" InitRoutine="Initialize">

            <RuntimeObject  Name="XXX" >

              <Description>Provide QNG common services</Description>

              <Method Name="beginTest" Routine="beginTest">This service is to init setup before test</Method>

              <Method Name="endTest" Routine="endTest">This service is to clean up after test</Method>

            </RuntimeObject>

          </Script>

          <Description>Provides QNG Service Object.</Description>

        </ScriptExtension>

      </Category>

    </ScriptExtensionGroup>





    // ...


    function beginTest() {

      Log.Message( "---> beginTest()" );

      // ...

    }


    function endTest() {

      Log.Message( "---> endTest()" );

      // ...

    }


    function Initialize(){

      Log.Message("---> Initialize()");

      // ...

    }