use of org.jenkinsci.test.acceptance.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class AnalysisCollectorPluginTest method addAndConfigureWarningsPublisher.
private void addAndConfigureWarningsPublisher(final FreeStyleJob job) {
WarningsBuildSettings warningsSettings = job.addPublisher(WarningsBuildSettings.class);
AnalysisConfigurator<WarningsBuildSettings> warningsConfigurator = settings -> {
settings.addWorkspaceScanner("Java Compiler (javac)", "**/*");
settings.addWorkspaceScanner("JavaDoc Tool", "**/*");
settings.addWorkspaceScanner("MSBuild", "**/*");
};
warningsConfigurator.accept(warningsSettings);
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob 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.po.FreeStyleJob in project acceptance-test-harness by jenkinsci.
the class CheckStylePluginTest method should_report_new_and_fixed_warnings_in_consecutive_builds.
/**
* Runs job two times to check if new and fixed warnings are displayed. Afterwards, the first build
* is deleted and Jenkins is restarted. Then the results of the second build are validated again: the detail
* pages should then show the same results (see JENKINS-24940).
*/
@Test
@Issue("24940")
public void should_report_new_and_fixed_warnings_in_consecutive_builds() {
assumeTrue("This test requires a restartable Jenkins", jenkins.canRestart());
FreeStyleJob job = createFreeStyleJob();
Build firstBuild = buildJobAndWait(job);
replaceResource(FILE_FOR_2ND_RUN, job);
Build lastBuild = buildSuccessfulJob(job);
assertThatCheckStyleResultExists(job, lastBuild);
lastBuild.open();
verifyWarningCounts(lastBuild);
firstBuild.delete();
jenkins.restart();
lastBuild.open();
verifyWarningCounts(lastBuild);
}
use of org.jenkinsci.test.acceptance.po.FreeStyleJob 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.po.FreeStyleJob 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"));
}
Aggregations