JenkinsPipelineUnit
JenkinsPipelineUnit copied to clipboard
Cannot get loadInterceptor from PipelineTestHelper
I need to add some custom actions before loading script in load step.
It would be if I could do something like that
class TestExample extends BaseRegressionTest {
@Before
@Override
void setUp() {
super.setUp()
def loadInterceptor = helper.loadInterceptor
def customLoadInterceptor = {String scriptName ->
//custom actions
loadInterceptor.setDelegate(delegate)
loadInterceptor(scriptName)
}
helper.registerAllowedMethod('load', [String.class], customLoadInterceptor)
}
But currently loadInterceptor has protected access visibility. Is it possible to make it public or there is something that requires it to be protected?
Hi @vitalii-vitrenko,
Sorry for the late response, I don't know if my response will be still relevant,
To add a custom action to loadInterceptor you can extend the PipelineTestHelper class, and reregister the load method with your new implementation. You can of course call the default implementation, just make sure that method/field names are not the same, ie getLoadInterceptor etc.
You can then go ahead and override it inside the setUp (before calling the setUp method of BasePipelineTest), as helper = new MyPipelineTestHelper()
Hope that helps,