JenkinsPipelineUnit - Junit are runs but nothing shows in the console

Hi all,

I am trying to use JenkinsPipelineUnit.
I am using Maven, and defined Junits (one in JAVA and one in Groovy).
The framework found the Junit and run them, but there is not trace or other prints in the console.

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?
Thanks.

“it doesn’t work” is always hard to remote debug. Try to always include these 3 things.

  1. what did you try (the code you provided would fit this)
  2. what did happen? (Error messages, description, outputs, stuff)
  3. 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.

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.
I accept to see something in the console - but nothing.
The junit success even when I change the sh script to “exit -1”

What would you expect to see in the console?

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.

Thank you, now I get the trace in the console.