JenkinsPipelineUnit
JenkinsPipelineUnit copied to clipboard
methodInterceptor closure passed to Script invokeMethod has wrong signature?
https://github.com/lesfurets/JenkinsPipelineUnit/blob/4c86c064146e45185a1621062fd0257bc293b4bf/src/main/groovy/com/lesfurets/jenkins/unit/PipelineTestHelper.groovy#L130
I updated to JenkinsPipelineUnit v1.1 and found that my mocks are being called with single element arrays where I might expect say just a string (e.g args value of ["foo"] instead of "foo").
The invokeMethod signature for Script is defined here: http://docs.groovy-lang.org/2.4.11/html/gapi/groovy/lang/Script.html
The expected signature is:
public Object invokeMethod(String name, Object args)
But the signature for what is used in the helper is passing args as an array:
public methodInterceptor = { String name, Object[] args ->
It affected my project here where I get args using Spock mocks and have to de-reference the array: https://github.com/macg33zr/pipelineUnit/blob/52eae8392f4ddb1460988ea1b31ecb0d301a7fbb/pipelineTests/groovy/tests/job/JenkinsfileTestSpec.groovy#L30
It is a bit subtle and can be worked around (change all tests though!).
What do you think is this an issue or a feature?
Best regards, Bill
Hi Bill,
I agree it is indeed a bit subtle. We had issues with this signature in the past, I am not sure which is the best solution, I’ll look and get back to you.
For now you can hold the migration to 1.1. There are other issues with it as well cf #60
I am facing the same issue, has anything changed since this issue was reported?