use of org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStyleAction in project acceptance-test-harness by jenkinsci.
the class CheckStylePluginTest method should_show_warnings_per_user.
/**
* Verifies that blaming of warnings works on agents: creates a new project in a Git repository in a docker
* container. Registers the same docker container as slave agent to build the project. Uses the recorded build
* results in checkstyle-result.xml (no actual maven goal is invoked). Verifies that the blame information is
* correctly assigned for each of the warnings. Also checks, that the age is increased for yet another build.
*/
@Test
@WithPlugins({ "git", "dashboard-view", "analysis-core@1.88-SNAPSHOT", "ssh-slaves" })
@WithDocker
@Issue("JENKINS-6748")
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
public void should_show_warnings_per_user() {
// avoid JENKINS-49026
jenkins.restart();
DumbSlave agent = createDockerAgent();
String gitRepositoryUrl = createGitRepositoryInDockerContainer();
FreeStyleJob job = createFreeStyleJob(jenkins, null, settings -> settings.pattern.set("**/checkstyle-result.xml"));
job.configure(() -> {
job.useScm(GitScm.class).url(gitRepositoryUrl).credentials(CREDENTIALS_ID);
job.setLabelExpression(agent.getName());
});
buildSuccessfulJob(job);
CheckStyleAction action = new CheckStyleAction(job);
action.open();
SortedMap<String, Integer> expectedPeople = new TreeMap<>();
expectedPeople.put("Unknown authors", 1);
expectedPeople.put("Jenkins-ATH <jenkins-ath@example.org>", 11);
assertThat(action.getPeopleTabContents(), is(expectedPeople));
action.find(By.partialLinkText("Jenkins-ATH")).click();
assertThat(driver, hasContent("Checkstyle Warnings - Jenkins-ATH"));
action.open();
SortedMap<String, String> expectedOrigin = new TreeMap<>();
expectedOrigin.put("Main.java:0", "-");
expectedOrigin.put("Main.java:2", "Jenkins-ATH");
expectedOrigin.put("Main.java:4", "Jenkins-ATH");
expectedOrigin.put("Main.java:6", "Jenkins-ATH");
expectedOrigin.put("Main.java:9", "Jenkins-ATH");
expectedOrigin.put("Main.java:13", "Jenkins-ATH");
expectedOrigin.put("Main.java:18", "Jenkins-ATH");
expectedOrigin.put("Main.java:23", "Jenkins-ATH");
expectedOrigin.put("Main.java:24", "Jenkins-ATH");
expectedOrigin.put("Main.java:27", "Jenkins-ATH");
assertThat(action.getOriginTabContentsAsStrings(AUTHOR), is(expectedOrigin));
assertThatAgeIsAt(action, expectedOrigin, 1);
buildSuccessfulJob(job);
assertThatAgeIsAt(action, expectedOrigin, 2);
GraphConfigurationView view = action.configureTrendGraphForUser();
view.open();
view.setUserGraph();
view.save();
WebElement graph = find(getUsersTrendGraphXpath());
assertThat(graph.isDisplayed(), is(true));
verifyNoAuthors(action, true);
WebElement nothing = getElement(getUsersTrendGraphXpath());
assertThat(nothing, nullValue());
verifyNoAuthors(action, false);
}
use of org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStyleAction in project acceptance-test-harness by jenkinsci.
the class CheckStylePluginTest method should_retrieve_results_from_maven_job.
/**
* Builds a maven project and checks if new warning are displayed.
*/
@Test
public void should_retrieve_results_from_maven_job() {
MavenModuleSet job = createMavenJob();
Build build = buildSuccessfulJob(job);
assertThatCheckStyleResultExists(job, build);
build.open();
CheckStyleAction checkstyle = new CheckStyleAction(build);
checkstyle.open();
assertThat(checkstyle.getNumberOfNewWarnings(), is(12));
}
use of org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStyleAction in project acceptance-test-harness by jenkinsci.
the class CheckStylePluginTest method should_link_to_source_code_in_real_project.
/**
* Builds an existing freestyle project using actual maven commands and checks if new warning are displayed. Also
* verifies that the warnings have links to the actual source code and the source code view shows the affected
* line.
*/
@Test
public void should_link_to_source_code_in_real_project() {
FreeStyleJob job = createJob(jenkins, CHECKSTYLE_PLUGIN_ROOT + SAMPLE_CHECKSTYLE_PROJECT, FreeStyleJob.class, CheckStyleFreestyleSettings.class, settings -> settings.pattern.set("target/checkstyle-result.xml"));
setMavenGoal(job, "clean package checkstyle:checkstyle");
Build build = buildSuccessfulJob(job);
assertThatCheckStyleResultExists(job, build);
build.open();
CheckStyleAction checkstyle = new CheckStyleAction(build);
checkstyle.open();
assertThat(checkstyle.getNumberOfNewWarnings(), is(12));
SortedMap<String, String> expectedContent = new TreeMap<>();
expectedContent.put("Main.java:0", "JavadocPackageCheck");
expectedContent.put("Main.java:2", "HideUtilityClassConstructorCheck");
expectedContent.put("Main.java:4", "JavadocVariableCheck");
expectedContent.put("Main.java:6", "FinalParametersCheck");
expectedContent.put("Main.java:9", "WhitespaceAroundCheck");
expectedContent.put("Main.java:13", "WhitespaceAroundCheck");
expectedContent.put("Main.java:18", "WhitespaceAroundCheck");
expectedContent.put("Main.java:23", "JavadocMethodCheck");
expectedContent.put("Main.java:24", "MagicNumberCheck");
expectedContent.put("Main.java:27", "JavadocMethodCheck");
assertThat(checkstyle.getWarningsTabContents(), is(expectedContent));
verifySourceLine(checkstyle, "Main.java", 27, "27 public static int return8() {", "Checks the Javadoc of a method or constructor.");
}
use of org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStyleAction in project acceptance-test-harness by jenkinsci.
the class CheckStylePluginTest method should_resolve_environment_variables.
/**
* Verifies that environment variables are expanded in the file name pattern.
*/
@Test
@Issue("JENKINS-30735")
@WithPlugins({ "envinject", "analysis-core@1.77", "checkstyle@3.46" })
public void should_resolve_environment_variables() {
FreeStyleJob job = createFreeStyleJob(settings -> settings.pattern.set("checkstyle${ENV_DASH}result.xml"));
job.configure(() -> new EnvInjectConfig.Environment(job).properties.sendKeys("ENV_DASH=-"));
Build build = buildSuccessfulJob(job);
assertThatCheckStyleResultExists(job, build);
CheckStyleAction action = new CheckStyleAction(job);
assertThatWarningsCountInSummaryIs(action, TOTAL_NUMBER_OF_WARNINGS);
assertThatNewWarningsCountInSummaryIs(action, TOTAL_NUMBER_OF_WARNINGS);
assertThat(build.getConsole(), containsRegexp("\\[CHECKSTYLE\\] Searching for all files in .* that match the pattern checkstyle-result.xml\n"));
}
use of org.jenkinsci.test.acceptance.plugins.checkstyle.CheckStyleAction in project acceptance-test-harness by jenkinsci.
the class CheckStylePluginTest method verifyWarningCounts.
private void verifyWarningCounts(final Build build) {
CheckStyleAction action = new CheckStyleAction(build);
assertThatWarningsCountInSummaryIs(action, 679);
assertThatNewWarningsCountInSummaryIs(action, 2);
assertThatFixedWarningsCountInSummaryIs(action, 99);
action.open();
assertThat(action.getNumberOfWarnings(), is(679));
assertThat(action.getNumberOfNewWarnings(), is(2));
assertThat(action.getNumberOfFixedWarnings(), is(99));
assertThat(action.getNumberOfWarningsWithHighPriority(), is(679));
assertThat(action.getNumberOfWarningsWithNormalPriority(), is(0));
assertThat(action.getNumberOfWarningsWithLowPriority(), is(0));
action.openNew();
assertThat(action.getNumberOfWarningsWithHighPriority(), is(2));
assertThat(action.getNumberOfWarningsWithNormalPriority(), is(0));
assertThat(action.getNumberOfWarningsWithLowPriority(), is(0));
action.openFixed();
assertThat(action.getNumberOfRowsInFixedWarningsTable(), is(99));
}
Aggregations