Class RealJenkinsFixture

java.lang.Object
org.jvnet.hudson.test.fixtures.RealJenkinsFixture

public class RealJenkinsFixture extends Object
Like JenkinsSessionFixture but running Jenkins in a more realistic environment.

Though Jenkins is run in a separate JVM using Winstone (java -jar jenkins.war), you can still do “whitebox” testing: directly calling Java API methods, starting from JenkinsRule or not. This is because the test code gets sent to the remote JVM and loaded and run there. (Thus when using Maven, there are at least three JVMs involved: Maven itself; the Surefire booter with your top-level test code; and the Jenkins controller with test bodies.) Just as with JenkinsRule, all plugins found in the test classpath will be enabled, but with more realistic behavior: class loaders in a graph, pluginFirstClassLoader and maskClasses, etc.

“Compile-on-save” style development works for classes and resources in the current plugin: with a suitable IDE, you can edit a source file, have it be sent to target/classes/, and rerun a test without needing to go through a full Maven build cycle. This is because target/test-classes/the.hpl is used to load unpacked plugin resources.

Like JenkinsRule, the controller is started in “development mode”: the setup wizard is suppressed, the update center is not checked, etc. Usage:


 private static final RealJenkinsFixture FIXTURE = new RealJenkinsFixture();

 public void method() {
     try {
         FIXTURE.setUp([…]);
         FIXTURE.runRemotely(() -> […]);
     } finally {
         FIXTURE.tearDown();
     }
 }
 

Known limitations:

See Also: