You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try {
resultJSON = readJSON text: scriptResult?.trim()
} catch (ex) {
echo 'The response is may not be in JSON format/No error received. \n Exception received trying to parse result as JSON : ' + ex
}
I am trying to mock the readJSON and get resultJSON populated with some value.
The mocking will look for an exact match of the arguments passed in. It has to be a map (AFAIK), not a string-ified object such as your first two examples. Here's an example that I have working with a readJSONmock.
Expected Behavior
def resultJSON = ''
try {
resultJSON = readJSON text: scriptResult?.trim()
} catch (ex) {
echo 'The response is may not be in JSON format/No error received. \n Exception received trying to parse result as JSON : ' + ex
}
I am trying to mock the readJSON and get resultJSON populated with some value.
String resTxt = "testString"
String resTxt = "{'test':'value'}"
getPipelineMock("readJSON").call(["[text:'test value']"]) >> { return resTxt}
or
getPipelineMock("readJSON").call(["{'test':'value'}"]) >> { return resTxt}
or any other value even line below....
getPipelineMock("readJSON").call([[text:null]]) >> { return resTxt}
should be returning a value provided with return statement or should throw an exception.
Actual Behavior
Below block is seen anyways.
And nothing is returned.
17:01:32.221 [main] DEBUG com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification - TEST FIXTURE intercepted & redirected a call:
Test : class com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification
Note : pipeline step
Via : [email protected]
(types) : queryWebUrl.methodMissing
Invocation : [email protected]([[text:null]])
(types) : queryWebUrl.readJSON(Object[])
Forwarded To : Mock for type 'Closure' named 'getPipelineMock("readJSON")'.call([text:null])
(types) : Closure$$EnhancerByCGLIB$$94f4fb1c.call(LinkedHashMap)
The text was updated successfully, but these errors were encountered: