Skip to content

Commit

Permalink
Add IT
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-epure-sonarsource committed Jun 9, 2022
1 parent 2d026fc commit 8e5eb6d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,24 @@ public void testExcludedAndTest_simulateAzureDevopsEnvironmentSetting_ExcludeTes
testExcludedAndTest(build, "ExcludedTest_True_FromAzureDevOps", projectDir, token, 0, true);
}

@Test
public void testExcludedAndTest_simulateAzureDevopsEnvironmentSettingMalformedJson_LogsError() throws Exception {
String projectKeyName = "ExcludedTest_MalformedJson_FromAzureDevOps";
String token = TestUtils.getNewToken(ORCHESTRATOR);
Path projectDir = TestUtils.projectDir(temp, "ExcludedTest");
ScannerForMSBuild beginStep = TestUtils.newScannerBegin(ORCHESTRATOR, projectKeyName, projectDir, token, ScannerClassifier.NET_FRAMEWORK_46);
ORCHESTRATOR.getServer().restoreProfile(FileLocation.of("projects/ProjectUnderTest/TestQualityProfile.xml"));
ORCHESTRATOR.getServer().provisionProject(projectKeyName, projectKeyName);
ORCHESTRATOR.getServer().associateProjectToQualityProfile(projectKeyName, "cs", "ProfileForTest");

ORCHESTRATOR.executeBuild(beginStep);
EnvironmentVariable sonarQubeScannerParams = new EnvironmentVariable("SONARQUBE_SCANNER_PARAMS", "{\"sonar.dotnet.excludeTestProjects\" }");
BuildResult msBuildResult = TestUtils.runMSBuildQuietly(ORCHESTRATOR, projectDir, Collections.singletonList( sonarQubeScannerParams ), "/t:Rebuild");

assertThat(msBuildResult.isSuccess()).isFalse();
assertThat(msBuildResult.getLogs()).contains("Failed to parse properties from the environment variable 'SONARQUBE_SCANNER_PARAMS' because 'Invalid character after parsing property name. Expected ':' but got: }. Path '', line 1, position 36.'.");
}

@Test
public void testMultiLanguage() throws Exception {
String localProjectKey = PROJECT_KEY + ".12";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private static Path getNuGetPath(Orchestrator orch) {
return nugetPath;
}

private static BuildResult runMSBuildQuietly(Orchestrator orch, Path projectDir, List<EnvironmentVariable> environmentVariables, String... arguments) {
public static BuildResult runMSBuildQuietly(Orchestrator orch, Path projectDir, List<EnvironmentVariable> environmentVariables, String... arguments) {
Path msBuildPath = getMsBuildPath(orch);

BuildResult result = new BuildResult();
Expand Down

0 comments on commit 8e5eb6d

Please sign in to comment.