Skip to content

Instantly share code, notes, and snippets.

@nmrao
Last active July 8, 2021 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmrao/7e7f2a30e0096e2bcaf9bf6b291da11d to your computer and use it in GitHub Desktop.
Save nmrao/7e7f2a30e0096e2bcaf9bf6b291da11d to your computer and use it in GitHub Desktop.
/**
* This script sets value for the swagger Compliance URL / File
* It is project level Setup Script
*/
//Read the project property, it can be passed from command line dynamically either file path or url
//On windows too, use / in the file path say,C:/temp/swagger.json
def newSwaggerUrl = context.expand('${#Project#SWAGGER_URL}')
//Closure to log the assertion value of swagger url
def showCurrentSwaggerUrl = { msg, s, k, t ->
log.info "${msg} ${s} => ${k} => ${t.name}'s configured swagger url is : ${t?.assertions['Swagger Compliance Assertion']?.swaggerUrl}"
}
//Get all the test steps which have 'Swagger Complicance Assertion and change the new value
project.testSuiteList.each { suite ->
suite.testCaseList.each { kase ->
kase.testStepList.each { step ->
if (step.metaClass.respondsTo(step, 'getAssertions') && step?.assertions['Swagger Compliance Assertion']) {
showCurrentSwaggerUrl('Before setting the value ', suite.name, kase.name, step)
step?.assertions['Swagger Compliance Assertion']?.setSwaggerUrl(newSwaggerUrl)
showCurrentSwaggerUrl('After setting the value ', suite.name, kase.name, step)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment