-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide
JenkinsRule.restart()
implementation (#716)
- Loading branch information
1 parent
cb93195
commit 46bda4f
Showing
3 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/org/jvnet/hudson/test/junit/jupiter/JUnit5JenkinsRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.jvnet.hudson.test.junit.jupiter; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.junit.runner.Description; | ||
import java.io.File; | ||
import java.net.URL; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.not; | ||
import static org.hamcrest.collection.IsCollectionWithSize.hasSize; | ||
|
||
/** | ||
* Test {@link JUnit5JenkinsRule}. | ||
*/ | ||
@WithJenkins | ||
class JUnit5JenkinsRuleTest { | ||
|
||
@Test | ||
void restart(JenkinsRule rule) throws Throwable { | ||
// preserve relevant properties | ||
URL previousUrl = rule.getURL(); | ||
Description previousTestDescription = rule.getTestDescription(); | ||
File previousRoot = rule.jenkins.getRootDir(); | ||
|
||
// create some configuration | ||
rule.createFreeStyleProject(); | ||
assertThat(rule.jenkins.getJobNames(), hasSize(1)); | ||
|
||
// restart the instance with same port and new JENKINS_HOME | ||
rule.restart(); | ||
|
||
// validate properties and configuration were preserved | ||
assertThat(rule.getURL(), equalTo(previousUrl)); | ||
assertThat(rule.getTestDescription(), equalTo(previousTestDescription)); | ||
assertThat(rule.jenkins.getRootDir(), not(previousRoot)); | ||
assertThat(rule.jenkins.getJobNames(), hasSize(1)); | ||
|
||
// validate restarted instance is working | ||
rule.createFreeStyleProject(); | ||
assertThat(rule.jenkins.getJobNames(), hasSize(2)); | ||
} | ||
|
||
} |