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
could it be some issues mocking a function/method inside the script block?
If there is any workaround for the cases like this?
thanks,
Expected Results
Expecting to be able to Mock getId() or Mock the entire library (L#174 buildInfoYaml() in this case), so, I can unit test just the .jenkinsfile alone.
The getId() is in Class Run as at here https://javadoc.jenkins-ci.org/hudson/model/Run.html
Actual Results
Task :test FAILED
TestOpenSearchDashboardsDistributionBuild > testDistributionBuild_Pipeline FAILED
java.lang.RuntimeException: integ-test - No signature of method: java.util.LinkedHashMap.getId() is applicable for argument types: () values: []
Possible solutions: get(java.lang.Object), get(java.lang.Object), get(java.lang.Object), getAt(java.lang.Object), getAt(java.lang.String), get(java.lang.Object, java.lang.Object),bwc-test - No signature of method: java.util.LinkedHashMap.getId() is applicable for argument types: () values: []
Possible solutions: get(java.lang.Object), get(java.lang.Object), get(java.lang.Object), getAt(java.lang.Object), getAt(java.lang.String), get(java.lang.Object, java.lang.Object)
Anything else?
No response
The text was updated successfully, but these errors were encountered:
jordarlu
changed the title
JenkinsPipelineUnit - unable to mock getId() called within parrallel
JenkinsPipelineUnit - unable to mock getId() called within script block
Oct 26, 2022
Jenkins and plugins versions report
Environment
What Operating System are you using (both controller, and any agents involved in the problem)?
I am running the unit test using JenkinsPipelineUnit framwork and test at my local Macbook
Reproduction steps
I try to come out a groovy test for a .jenkinsfile with using the JenkinsPipelineUnit framwork and test at my local Macbook.
In one of the .jenkinsfile which it has the following structure:
https://github.com/opensearch-project/opensearch-build/blob/main/jenkins/opensearch-dashboards/distribution-build.jenkinsfile#L159-L186
The getId() at L#176 is always caught error as " No signature of method: java.util.LinkedHashMap.getId() is applicable for argument types: () values: []
Possible solutions: get(java.lang.Object), get(java.lang.Object), get(java.lang.Object), getAt(java.lang.Object), getAt(java.lang.String), get(java.lang.Object, java.lang.Object)"
I have tried the following but still no luck
could it be some issues mocking a function/method inside the script block?
If there is any workaround for the cases like this?
thanks,
Expected Results
Expecting to be able to Mock getId() or Mock the entire library (L#174 buildInfoYaml() in this case), so, I can unit test just the .jenkinsfile alone.
The getId() is in Class Run as at here https://javadoc.jenkins-ci.org/hudson/model/Run.html
Actual Results
TestOpenSearchDashboardsDistributionBuild > testDistributionBuild_Pipeline FAILED
java.lang.RuntimeException: integ-test - No signature of method: java.util.LinkedHashMap.getId() is applicable for argument types: () values: []
Possible solutions: get(java.lang.Object), get(java.lang.Object), get(java.lang.Object), getAt(java.lang.Object), getAt(java.lang.String), get(java.lang.Object, java.lang.Object),bwc-test - No signature of method: java.util.LinkedHashMap.getId() is applicable for argument types: () values: []
Possible solutions: get(java.lang.Object), get(java.lang.Object), get(java.lang.Object), getAt(java.lang.Object), getAt(java.lang.String), get(java.lang.Object, java.lang.Object)
Anything else?
No response
The text was updated successfully, but these errors were encountered: