Forum Discussion

DanNad's avatar
DanNad
Contributor
2 years ago

Get the Testname / Routine Name when not ran via execution plan

I cant seem to find a good way to do this.

 

Following variables

'aqTestCase.CurrentTestCase.Name' or 'Project.TestItems.Current.Name '

 

do seem to work only when the test is executed via execution plan. When i execute the test directly i get 'undefined'

Is there a reliable way to get the test name independent of the execution plan?

5 Replies

  • MW_Didata's avatar
    MW_Didata
    Regular Contributor

    Hmm, doesn't work for me either, the variable stays empty.

    Maybe contacting TC support can get you the answers you need.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Usage,

     

    function one()
    {
        aqTestCase.Begin("One");
        Log.Message("Test One");
        Log.Message(aqTestCase.CurrentTestCase.Name);
        aqTestCase.End();
    }

     

    As mentioned, The aqTestCase.CurrentTestCase property returns information on the test case that is currently running. It can be: The tests specified in the Execution Plan editor of your project. By default, TestComplete treats all the tests added to the editor as test cases. Code fragments marked as test cases by using the aqTestCase.Begin and aqTestCase.End methods. Tests that are run by specifying their tags. BDD scenarios.

     

    • DanNad's avatar
      DanNad
      Contributor

      rraghvani wrote:

      Usage,

       

       

       

      function one()
      {
          aqTestCase.Begin("One");
          Log.Message("Test One");
          Log.Message(aqTestCase.CurrentTestCase.Name);
          aqTestCase.End();
      }

       

       

       

      As mentioned, The aqTestCase.CurrentTestCase property returns information on the test case that is currently running. It can be: The tests specified in the Execution Plan editor of your project. By default, TestComplete treats all the tests added to the editor as test cases. Code fragments marked as test cases by using the aqTestCase.Begin and aqTestCase.End methods. Tests that are run by specifying their tags. BDD scenarios.

       



      Thanks for the explanation. Im afraid it would be a lot of work. In order to make this work with "aqTestCase.Begin..." i would have to modify 300+ Testscripts
      Is there a more "automated" way. For example i have a Testscript MyTest.sj and i would like to get just the name of the current MyTest.sj and just remove the file extension.

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        What rraghvani explained *is* the automated way to do it.  Before that feature was available, we had to save the test name in a variable at the top of every script and keep track of it ourselves.

         

        With your tests, what I suggest doing is adding this feature into any new tests you are adding or in ones that you are editing. Next you can add it into the tests that run most often. Do the changes a little at a time and not try to do all 300+ at once.

         

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I can't think of any other simple ways of doing this.

     

    Is the log output not good enough to view the details?