Forum Discussion

shilpa16's avatar
shilpa16
Occasional Contributor
31 days ago

Set-up script works locally but throws an Script exception when running from pipeline - TestEngine

Hello,

I have a set-up script that reads an auth token from a file and replaces a Project property.

This script work fine locally but throws an exception in Azure pipeline where I'm using ReadyAPI TestEngine to run the tests. The log message isn't helpful.

Not sure where and why the exception is thrown, appreciate any help.

def tokenFromProperties = runner.project.getPropertyValue("AuthToken")
log.info("Current Token from suite properties ----   " +  tokenFromProperties )

def projectPath = runner.project.getProject().path
//log.info(projectPath)

def filePath = projectPath + "/SignedJWT.txt"
//log.info(filePath)

def myFile = new File(filePath)
def myScanner = new Scanner(myFile)
def tokenFromFile = myScanner.nextLine()
log.info("Token from the text file ---" + tokenFromFile)
myScanner.close()

//testrunner.testCase.testSuite.setPropertyValue("Token", "test")
runner.project.setPropertyValue("AuthToken", tokenFromFile)
def UpdatedTokenFromProperties = runner.project.getPropertyValue("AuthToken")
log.info("Updated Token from suite properties --- " +  UpdatedTokenFromProperties)

 

 

8 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    Better open a ticket with Customer support of Smartbear.

  • nmrao's avatar
    nmrao
    Champion Level 3

    shilpa16 

    Looks missed your comments as they were not noticeable  and later you seemed to highlight the same.

    How do you run the project in testengine? I mean the command.

  • nmrao's avatar
    nmrao
    Champion Level 3

    shilpa16 

    I assume, "runner." is removed in all places of the script.

    First try it on your machine and then on testengine.

  • nmrao's avatar
    nmrao
    Champion Level 3

    shilpa16 

    Thanks.

    Could you please try the below and update ?

    • try to launch testrunner from with in ReadyAPI tool and see if the same is the behavior
    • try to provide the absolute path of the token file?
      • if that is not possible, then use project custom property for the token file and pass the file path runtime? Refer -P argument
    • now see if the above log shows the log statement
    • If both the above did not help, also try below change i.e., remove runner

    from

    runner.project.getPropertyValue("AuthToken")

    to

    project.getPropertyValue("AuthToken")

     

     

    • shilpa16's avatar
      shilpa16
      Occasional Contributor
      • try to launch testrunner from with in ReadyAPI tool and see if the same is the behavior - Nope it is working locally 
      • try to provide the absolute path of the token file?
        • if that is not possible, then use project custom property for the token file and pass the file path runtime? Refer -P argument - Is there a way to pass the -P argument from the Run ReadyAPI Projects in TestEngine?
      • If both the above did not help, also try below change i.e., remove runner - This worked atleast the exception is gone but the Token is still not being replaced. This returns the path with backward slashes runner.project.getProject().path, wondering if this is causing any issues?

       

      nmrao 

  • nmrao's avatar
    nmrao
    Champion Level 3
    shilpa16 wrote:

    def tokenFromProperties = runner.project.getPropertyValue("AuthToken")

    shilpa16

    • setup script ? what level? test suite / project / test case?
    • Is the project and the token file are at the same level on the machine where test engine is running?
    • does it show the value for below?

    log.info("Token from the text file ---" + tokenFromFile)

    • shilpa16's avatar
      shilpa16
      Occasional Contributor
      • The setup script is at the Project level.
      • Yes, they are.
      • No, I couldn't find any of the log info output in the pipeline. nmrao