JenkinsPipelineUnit icon indicating copy to clipboard operation
JenkinsPipelineUnit copied to clipboard

Cannot get loadInterceptor from PipelineTestHelper

Open vitalii-vitrenko opened this issue 8 years ago • 1 comments

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?

vitalii-vitrenko avatar Jul 17 '17 12:07 vitalii-vitrenko

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,

ozangunalp avatar Aug 30 '17 20:08 ozangunalp