OsFr  
                
                  
                    January 16, 2022, 10:49am
                   
                  1 
               
             
            
              Hi all,
I am trying to use JenkinsPipelineUnit.
The junit look like this:
import com.lesfurets.jenkins.unit.BasePipelineTest;
import groovy.lang.Script;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class TestSimpleIDIBuild extends BasePipelineTest {
	@Override
	@BeforeAll
	public void setUp() throws Exception {
		super.setScriptRoots("vars");
		super.setScriptExtension("groovy");
		super.setUp();	}
	@Test
	public void should_execute_without_errors() throws Exception {
		Script script = loadScript("simpleXXXBuild.groovy");
		script.run();
		super.printCallStack();
		assertJobStatusSuccess();
	}
}
Do you have any idea?
             
            
              
            
           
          
            
              
                halkeye  
              
                  
                    January 17, 2022,  8:28am
                   
                  2 
               
             
            
              “it doesn’t work” is always hard to remote debug. Try to always include these 3 things.
what did you try (the code you provided would fit this) 
what did happen? (Error messages, description, outputs, stuff) 
what did you expect to happen? 
 
Otherwise it’s hard for us to get into your context and you’ll have to have someone who is exactly knowledgeable come along.
             
            
              
            
           
          
            
              
                OsFr  
              
                  
                    January 17, 2022,  8:42am
                   
                  3 
               
             
            
              my simpleXXXBuild.groovy look like:
def call(Map config = [:]) {
   pipeline {
      agent any
      stages {
         stage ('Run clean install') {
            steps {
               sh 'mvn clean install'
            }
         }
      }
}
}
The junit run successfully.
             
            
              
            
           
          
            
              
                halkeye  
              
                  
                    January 17, 2022,  8:59am
                   
                  4 
               
             
            
              
What would you expect to see in the console?
 OsFr:
 
		script.run();
 
 
The examples in the readme seem to have .execute() not .run() (run they have for libraries, which don’t use loadScript)
Just going by the readme. I think the script you load should call your function, not be the function itself. since your def call is just creating a function simpleXXXBuild() not doing anything.
             
            
              
            
           
          
            
              
                OsFr  
              
                  
                    January 17, 2022, 12:09pm
                   
                  5 
               
             
            
              Thank you, now I get the trace in the console.