griddynamics / mpl

[IT-36925] Jenkins Shared Modular Pipeline Library
https://blog.griddynamics.com/developing-a-modular-pipeline-library-to-improve-devops-collaboration/
Apache License 2.0
158 stars 97 forks source link

Tests: Script loading global vars overrides registerAllowedMethod #22

Closed sparshev closed 5 years ago

sparshev commented 5 years ago

When the MPLModule or any other script loads - it can override the registerAllowedMethod with included vars steps Global Vars. This behavior don't allow to mock the custom steps we don't need to test.

Proposed way to fix: override function registerAllowedMethod(MethodSignature methodSignature, Closure closure) and check existence of such allowed method by isMethodAllowed before adding the data to allowedMethodCallbacks. This function is used by the internal helper setGlobalVars and with changes will not allow to override already set mocks. Also it will be possible to override the allowed methods manually using registerAllowedMethod(String name, List<Class> args = [], Closure closure) helper method.

sparshev commented 5 years ago

OMG, found issue.

sparshev commented 5 years ago

Yep, now it's working.

sparshev commented 5 years ago

Fixed in #24