Skip to content

Commit

Permalink
SONARJNKNS-255 Fix ITs
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Jun 6, 2016
1 parent b9f159b commit 2fc2a98
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
19 changes: 0 additions & 19 deletions its/src/test/java/com/sonar/it/jenkins/JenkinsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,6 @@ public void testFreestyleJobWithSonarRunner() throws Exception {
jenkins.assertQGOnProjectPage(jobName);
}

@Test
public void testFreestyleJobWithMsBuildSQRunner() {
File toolPath = new File(jenkins.getServer().getHome().getAbsolutePath() + File.separator + "tools" + File.separator + "hudson.plugins.sonar.MsBuildSQRunnerInstallation");
String jobName = "abacus-msbuild-sq-runner";
String projectKey = "abacus-msbuild-sq-runner";
assertThat(orchestrator.getServer().getWsClient().find(ResourceQuery.create(projectKey))).isNull();
BuildResult result = jenkins
.newFreestyleJobWithMsBuildSQRunner(jobName, null, new File("projects", "abacus"), projectKey, "Abacus with space", "1.0")
.executeJobQuietly(jobName);

assertThat(result.getLogs())
.contains(
"tools" + File.separator + "hudson.plugins.sonar.MsBuildSQRunnerInstallation" + File.separator + "SQ_runner" + File.separator
+ "MSBuild.SonarQube.Runner.exe begin /k:abacus-msbuild-sq-runner \"/n:Abacus with space\" /v:1.0 /d:sonar.host.url="
+ orchestrator.getServer().getUrl());

assertThat(toolPath).isDirectory();
}

@Test
public void testFreestyleJobWithSonarRunnerAndBranch() throws Exception {
String jobName = "abacus-runner-branch";
Expand Down
38 changes: 38 additions & 0 deletions its/src/test/java/com/sonar/it/jenkins/JenkinsWithoutMaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,44 @@ public void testFreestyleJobWithSonarRunner_use_sq_scanner_2_6_1() throws Except
assertThat(result.getLogs()).contains("SonarQube Scanner 2.6.1");
}

@Test
public void testFreestyleJobWithMsBuildSQRunner_2_0() {
File toolPath = new File(jenkins.getServer().getHome().getAbsolutePath() + File.separator + "tools" + File.separator + "hudson.plugins.sonar.MsBuildSQRunnerInstallation");
String jobName = "abacus-msbuild-sq-runner-2-0";
String projectKey = "abacus-msbuild-sq-runner-2-0";
assertThat(orchestrator.getServer().getWsClient().find(ResourceQuery.create(projectKey))).isNull();
BuildResult result = jenkins
.newFreestyleJobWithMsBuildSQRunner(jobName, null, new File("projects", "abacus"), projectKey, "Abacus with space", "1.0", "2.0")
.executeJobQuietly(jobName);

assertThat(result.getLogs())
.contains(
"tools" + File.separator + "hudson.plugins.sonar.MsBuildSQRunnerInstallation" + File.separator + "Scanner_for_MSBuild_2.0" + File.separator
+ "MSBuild.SonarQube.Runner.exe begin /k:" + projectKey + " \"/n:Abacus with space\" /v:1.0 /d:sonar.host.url="
+ orchestrator.getServer().getUrl());

assertThat(toolPath).isDirectory();
}

@Test
public void testFreestyleJobWithMsBuildSQRunner_1_1() {
File toolPath = new File(jenkins.getServer().getHome().getAbsolutePath() + File.separator + "tools" + File.separator + "hudson.plugins.sonar.MsBuildSQRunnerInstallation");
String jobName = "abacus-msbuild-sq-runner-1-1";
String projectKey = "abacus-msbuild-sq-runner-1-1";
assertThat(orchestrator.getServer().getWsClient().find(ResourceQuery.create(projectKey))).isNull();
BuildResult result = jenkins
.newFreestyleJobWithMsBuildSQRunner(jobName, null, new File("projects", "abacus"), projectKey, "Abacus with space", "1.0", "1.1")
.executeJobQuietly(jobName);

assertThat(result.getLogs())
.contains(
"tools" + File.separator + "hudson.plugins.sonar.MsBuildSQRunnerInstallation" + File.separator + "Scanner_for_MSBuild_1.1" + File.separator
+ "MSBuild.SonarQube.Runner.exe begin /k:" + projectKey + " \"/n:Abacus with space\" /v:1.0 /d:sonar.host.url="
+ orchestrator.getServer().getUrl());

assertThat(toolPath).isDirectory();
}

@Test
public void testNoSonarPublisher() {
String jobName = "no Sonar Publisher";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public JenkinsOrchestrator newFreestyleJobWithSQScanner(String jobName, @Nullabl
}

public JenkinsOrchestrator newFreestyleJobWithMsBuildSQRunner(String jobName, @Nullable String additionalArgs, File projectPath, String projectKey, String projectName,
String projectVersion) {
String projectVersion, @Nullable String msbuildScannerVersion) {
newFreestyleJobConfig(jobName, projectPath);

findElement(buttonByText("Add build step")).click();
Expand All @@ -285,6 +285,10 @@ public JenkinsOrchestrator newFreestyleJobWithMsBuildSQRunner(String jobName, @N
setTextValue(findElement(By.name("_.projectName")), projectName);
setTextValue(findElement(By.name("_.projectVersion")), projectVersion);

if (msbuildScannerVersion != null) {
select(findElement(By.name("msBuildScannerInstallationName")), getScannerMSBuildInstallName(msbuildScannerVersion));
}

if (additionalArgs != null) {
setTextValue(findElement(By.name("_.additionalArguments")), additionalArgs);
}
Expand Down Expand Up @@ -383,7 +387,7 @@ public JenkinsOrchestrator configureMsBuildSQScanner_installation(String version

findElement(buttonByText("Add SonarQube Scanner for MSBuild")).click();
setTextValue(findElement(By.name("_.name"), index), getScannerMSBuildInstallName(version));
new Select(findElement(By.name("_.id"), index)).selectByValue(version);
select(findElement(By.name("_.id"), index), version);
findElement(buttonByText("Save")).click();

return this;
Expand Down

0 comments on commit 2fc2a98

Please sign in to comment.