Forum Discussion

blbdt36's avatar
blbdt36
Contributor
10 years ago

Get name of TestSuite in script?

Is there any way to get the name of a TestSuite in a script?  I am creating a project for each of the major components of the application I am testing.  Right now, I want to pull the name so I can use the same ExportLog script for all by passing the name of the Project to be used in the file name instead of having the same function repeated for each component.  I am sure it will be useful elsewhere, but this is my current need.

 

Thanks.

  • Yea, I am probably going to do something like that.  

  • davel's avatar
    davel
    New Contributor

    strTest = Project.FileName

     

    returns the path and script (.mds)

    • blbdt36's avatar
      blbdt36
      Contributor

      Thanks for the suggestion.  That gets me closer, but there is still a lot of parsing I would have to do just to get the name.  I did some more digging and it doesn't seem to be an existing feature regardless of what the official documentation I found says.

       

       

      • jmcpeek's avatar
        jmcpeek
        Contributor

        You're correct, there's no way to get the project name itself other than parsing it out of the project.filename property. There are a couple of ways to work around this though:

         

        1- Use project.TestItems.Current.Name to get the name of the currently running test item, but that's for the test item itself, not the project. 

         

        2- Create a Persistent Variable on the Project that has a Local Value for how you want the project to be referenced. 

         

        Personally, I use option 2 for all my projects. I call the variable projectName and set the Local Value when I create the project. Then when I need to use it, I just use project.variables.projectName. I also have a corresponding variable at the project suite level called suiteName.

  • '*******************************************************************************************************************************************************
    'Function Name: ExtractProjectName
    'Description: It will Return Project Name from Project File Path
    'Parameters: Project.FileName
    'output: Project File Name without Extension
    'Example: ProjectName=ExtractProjectName(Project.FileName)
    '*******************************************************************************************************************************************************


    Function ExtractProjectName(ProjectFilePath)
    ProjectFilePath=Project.FileName
    Log.Message ProjectFilePath
    lastPosSlash=aqString.FindLast(ProjectFilePath,"\")
    lastpostDot=aqString.FindLast(ProjectFilePath,".")
    totalLength= aqString.GetLength(ProjectFilePath)
    a=aqString.SubString(ProjectFilePath,lastPosSlash+1,(lastpostDot-1)-lastPosSlash)
    ExtractProjectName =a
    End Function