Forum Discussion

mpartyka's avatar
mpartyka
Contributor
7 years ago

simple groovy - how to get project name?

I'd like to get the project name (label) using groovy.  I can get testCase Name, or Test Suite Name  (see below) ... but can't seem to get project name.  I must be missing something ?  Thanks in advance for any help !

 

def TestCaseName = testRunner.testCase.getLabel()
def TestSuiteName = testRunner.testCase.testSuite.getLabel()

 

  • Try this:

     

    def ProjectName= testRunner.testCase.testSuite.project.getName();
  • groovyguy's avatar
    groovyguy
    Community Hero

    Try this:

     

    def ProjectName= testRunner.testCase.testSuite.project.getName();
  • .getName(); instead of .getLabel() ... brilliant!    Why didn't I think of that!  ;)  
    Thanks for your help!
    • groovyguy's avatar
      groovyguy
      Community Hero

      More than welcome, always happy to help! :) 

  • Hi mpartyka,

     

    Yo can also try 

     

    def projectName = testRunner.testCase.testSuite.project.name

     

    Thanks,

    Himanshu Tayal