-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mission control view plugin: test basis and two test cases #320
Conversation
/** | ||
* {@link View} class of the mission control plugin. | ||
* | ||
* @author engelmi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want the credits put your real name here ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default at my pc, didn't heed it actually ;)
/** | ||
* Reloads the configuration of jenkins from disk. | ||
* Necessary to display the build history if a new {@link MissionControlView} is created. | ||
* (Inefficient) alternative: {@code jenkins.restart()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a bug of the plug-in? Or why is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required (see: https://wiki.jenkins-ci.org/display/JENKINS/Mission+Control+Plugin at "Setting Up"). I don't know how mission control works internally to display the build history, but it seems the plugin developers are aware of this behavior.
// (after the creation of a new mission control view the configuration needs to be reloaded) | ||
view.open(); | ||
WebElement buildHistory = driver.findElement(By.id("jenkinsBuildHistory")); | ||
Assert.assertEquals(0, buildHistory.findElements(By.xpath(".//tbody/tr")).size(), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Harmcrest matcher
assertThat(buildHistory.findElements(By.xpath(".//tbody/tr")), hasSize(0));
// open mission control view and assert that no build entries are being displayed | ||
// (after the creation of a new mission control view the configuration needs to be reloaded) | ||
view.open(); | ||
WebElement buildHistory = driver.findElement(By.id("jenkinsBuildHistory")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this be a method of the view so we can call view.getHistory()
.
// open mission control view again and assert that the n-builds are being displayed | ||
view.open(); | ||
buildHistory = driver.findElement(By.id("jenkinsBuildHistory")); | ||
Assert.assertEquals(historySize, buildHistory.findElements(By.xpath(".//tbody/tr")).size(), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harmcrest
buildHistory = driver.findElement(By.id("jenkinsBuildHistory")); | ||
Assert.assertEquals(historySize, buildHistory.findElements(By.xpath(".//tbody/tr")).size(), 0); | ||
// check for correct highlighting of the builds | ||
WebElement failedBuild = buildHistory.findElement(By.xpath(".//tbody/tr[td='" + strFailedJob + "']")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you plan to write more history tests then this code should be placed into a PageArea sub-class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I don't know how many tests of the build history will be written, but a PageArea seems to be a better approach. Should the View provide a method to create the PageArea object (as it is only valid if the view exists) or should the PageArea be decoupled from the View?
view.open(); | ||
// check for the correct highlighting of the jobs | ||
WebElement jobContainer = driver.findElement(By.id("jenkinsJobStatuses")); | ||
WebElement btnNotBuild = jobContainer.findElement(By.xpath("//button[text()='" + strJobNotBuild + "']")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract into method with parameter name
Implemented a basis for tests of the mission control plugin as well as two test cases.