Skip to content
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

Merged
merged 6 commits into from
Jun 15, 2017

Conversation

engelmi
Copy link
Contributor

@engelmi engelmi commented Jun 5, 2017

Implemented a basis for tests of the mission control plugin as well as two test cases.

/**
* {@link View} class of the mission control plugin.
*
* @author engelmi
Copy link
Member

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 ;-)

Copy link
Contributor

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()}
Copy link
Member

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?

Copy link
Contributor

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);
Copy link
Member

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"));
Copy link
Member

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);
Copy link
Member

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 + "']"));
Copy link
Member

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.

Copy link
Contributor

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 + "']"));
Copy link
Member

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

@olivergondza olivergondza merged commit 82147c0 into jenkinsci:master Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants