Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to mock variables/methods which are added in src packages #10

Open
mioyn opened this issue May 29, 2018 · 0 comments
Open

How to mock variables/methods which are added in src packages #10

mioyn opened this issue May 29, 2018 · 0 comments

Comments

@mioyn
Copy link

mioyn commented May 29, 2018

I have a common code in src folder, in package com.mycom.utils File : CommonStages.groovy Code:

    package com.mycom.utils
    def execute() {
      stage('some stage') {
        node ('someNode'){
          Println env.someenv
          
          }
         }
        }

Am getting no signature of method error com.mycom.utils.commonstages.stage() Is applicable for argument types: (java.lang.String, com.mycom.utils.commonsatges$_execute_closure1)

If the code is in jenkinsfile it executes but when I add it to the package structure it fails

test case using spock:

        def "common pipeline"() {
        given:
       

    when:

          helper.registerAllowedMethod('node', [Closure.class], null)
         helper.registerAllowedMethod("stage", [String.class], null)

         addEnvVar('PIPELINE_TYPE', 'PIPELINE_TYPE')
         def script = loadScript('Jenkinsfile')
        then:
        printCallStack()
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant