-
-
Save nmrao/7e7f2a30e0096e2bcaf9bf6b291da11d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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