Skip to content
Permalink
Browse files
[JENKINS-26913] Added test case that verifies the tab contents of a m…
…atrix build.
  • Loading branch information
uhafner committed Feb 23, 2015
1 parent 37f8c8e commit b5f5397361f77b7dd487a438eb7eb2264546234d
Showing with 57 additions and 3 deletions.
  1. +24 −2 src/main/java/org/jenkinsci/test/acceptance/plugins/analysis_core/AnalysisAction.java
  2. +33 −1 src/test/java/plugins/WarningsPluginTest.java
@@ -192,7 +192,7 @@ protected List<String> asTrimmedStringList(final List<WebElement> elems) {
}

/**
* Returns the first two columns of the "Categories"-tab as key => value pairs, skipping the header and footer
* Returns the first two columns of the "Files"-tab as key => value pairs, skipping the header and footer
* rows.
*
* @return a map of the first two columns. (first column => second column)
@@ -202,6 +202,28 @@ public SortedMap<String, Integer> getFileTabContents() {
return getContentsOfVisibleTable(true, true);
}

/**
* Returns the first two columns of the "Packages"-tab as key => value pairs, skipping the header and footer
* rows.
*
* @return a map of the first two columns. (first column => second column)
*/
public SortedMap<String, Integer> getPackagesTabContents() {
openTab(Tab.PACKAGES);
return getContentsOfVisibleTable(true, true);
}

/**
* Returns the first two columns of the "Modules"-tab as key => value pairs, skipping the header and footer
* rows.
*
* @return a map of the first two columns. (first column => second column)
*/
public SortedMap<String, Integer> getModulesTabContents() {
openTab(Tab.MODULES);
return getContentsOfVisibleTable(true, true);
}

/**
* Returns the first two columns of the "Categories"-tab as key => value pairs, skipping the header and footer
* rows.
@@ -374,6 +396,6 @@ public Integer getLinkedSourceFileLineNumber(final Tab tabId, final String fileN
}

public enum Tab {
FILES, PACKAGES, WARNINGS, DETAILS, FIXED, NEW, CATEGORIES, TYPES
MODULES, FILES, PACKAGES, WARNINGS, DETAILS, FIXED, NEW, CATEGORIES, TYPES
}
}
@@ -2,6 +2,8 @@

import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import org.apache.commons.lang3.StringUtils;
import org.jenkinsci.test.acceptance.junit.Bug;
@@ -45,7 +47,7 @@ public class WarningsPluginTest extends AbstractAnalysisTest {
* also verified (4, 6, and 2 warnings).
*/
// TODO: run the job twice and check for the graphs
@Test @Bug("11225")
@Test @Bug({"11225", "26913"})
public void should_report_warnings_per_axis() {
String file = "matrix-warnings.txt";
MatrixProject job = setupJob("/warnings_plugin/" + file, MatrixProject.class,
@@ -78,6 +80,36 @@ public void configure(WarningsBuildSettings settings) {
assertThat(driver, hasContent(title + ": " + warningsPerAxis.get(axis.name)));
}

assertThatConfigurationTabIsCorrectlyFilled(job);
assertThatFoldersTabIsCorrectlyFilled(job);
assertThatFilesTabIsCorrectlyFilled(job);
}

private void assertThatConfigurationTabIsCorrectlyFilled(final MatrixProject job) {
SortedMap<String, Integer> expectedConfigurationDetails = new TreeMap<>();
expectedConfigurationDetails.put("user_axis=one", 4);
expectedConfigurationDetails.put("user_axis=two", 6);
expectedConfigurationDetails.put("user_axis=three", 2);
WarningsAction action = new WarningsAction(job);
assertThat(action.getModulesTabContents(), is(expectedConfigurationDetails));
}

private void assertThatFoldersTabIsCorrectlyFilled(final MatrixProject job) {
SortedMap<String, Integer> expectedConfigurationDetails = new TreeMap<>();
expectedConfigurationDetails.put("axis/one", 4);
expectedConfigurationDetails.put("axis/two", 6);
expectedConfigurationDetails.put("axis/three", 2);
WarningsAction action = new WarningsAction(job);
assertThat(action.getPackagesTabContents(), is(expectedConfigurationDetails));
}

private void assertThatFilesTabIsCorrectlyFilled(final MatrixProject job) {
SortedMap<String, Integer> expectedConfigurationDetails = new TreeMap<>();
WarningsAction action = new WarningsAction(job);
expectedConfigurationDetails.put("FileOne.c", 4);
expectedConfigurationDetails.put("FileTwo.c", 6);
expectedConfigurationDetails.put("FileThree.c", 2);
assertThat(action.getFileTabContents(), is(expectedConfigurationDetails));
}

/**

0 comments on commit b5f5397

Please sign in to comment.