diff --git a/content/doc/developer/testing/index.adoc b/content/doc/developer/testing/index.adoc index 646a5edf4ba1..b470fe9f4bb8 100644 --- a/content/doc/developer/testing/index.adoc +++ b/content/doc/developer/testing/index.adoc @@ -367,7 +367,19 @@ report.copyFrom(getClass().getResourceAsStream("lint-results_r20.xml")); ---- ==== Customizing the `JENKINS_HOME` Directory -TODO: Write this section. + +If you want to adjust the `JENKINS_HOME` within a test, use the `JenkinsRule`-methods link:https://javadoc.jenkins.io/component/jenkins-test-harness/org/jvnet/hudson/test/JenkinsRule.html#withExistingHome(java.io.File)[`withExistingHome()`] or link:https://javadoc.jenkins.io/component/jenkins-test-harness/org/jvnet/hudson/test/JenkinsRule.html#withNewHome()[`withNewHome()`]. +Let's assume everything in the directory "src/test/resources/home" is prepared for a good test suite, which you should use. +This can be achieved with the following example: + +[source,java] +---- + + @Rule + public JenkinsRule j = new JenkinsRule().withExistingHome(new File("src/test/resources/home")); +---- + +If you need a fresh `JENKINS_HOME`, you can use `withNewHome()` to create a fresh home, which `JenkinsRule()` at the beginning defaults to. ==== Using `@LocalData` Runs a test case with a data set local to test method or the test class. This recipe allows your test case to start with the preset `JENKINS_HOME` data loaded either from your test method or from the test class.