Forum Discussion

sindhu10's avatar
sindhu10
Contributor
7 years ago

Is there a way to return the name of the current sub routine or function that is being run.

Hi All,

 

Is there a way to return the name of the current sub routine or function that is being run.

 

this will increase my traceability in logs and debugging .

 

Currently am coding in Jscript

 

Please help me with your suggestions.

 

Thanks,

sindhu

6 Replies

  • Hi All,



    Is there a way to return the name of the current sub routine or function that is being run. It would be nice to enter into the log.



    I am currently coding in JScript.



    I assume there is no way to do it using Jscript but is there a TestComplete inbuilt function?

     

    Thanks,

    sindhu

  • NisHera's avatar
    NisHera
    Valued Contributor

    Hi You can use test indicator

    push text method here is example and more

    (you to detect in run time..)

     

    if you need any message in Log you may use 

    Log.message("what ever you like")

    What exactly are you trying to achieve? there could be better solution if you describe your situation  

    • sindhu10's avatar
      sindhu10
      Contributor

      NisHera

       

      Thanks for the comments.

       

      Trying to achieve :

      Example :

      Function Test()

      {

      Test1();

      Test2();

      }

      I just want the logs in the form of folders like Test->Test1->Results

      Test2->Results

      this will help me in debugging which folder and which step goes wrong.

       

      Please suggest.

       

      Thanks,

      sindhu

      • shankar_r's avatar
        shankar_r
        Community Hero

        For that you have use Log.AppendFolder and Log.PopLogFolder option.

         

        Sample code would be like below,

         

        function testmycode(){
              Log.AppendFolder("testmycode");
              Test1();
              Test2();
              Log.PopLogFolder();
        }
        function Test1(){
              Log.AppendFolder("Test1");
              Log.Message("This is just a test");
              Log.Message("This is just a test1");
              Log.Message("This is just a test2");
              Log.PopLogFolder()
        }
        
        function Test2(){
              Log.AppendFolder("Test1");
              Log.Message("This is just a test");
              Log.Message("This is just a test1");
              Log.Message("This is just a test2");
              Log.PopLogFolder()
        }

        Output: