use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class UnitTestsTest method tests_with_report_name_suffix.
@Test
public void tests_with_report_name_suffix() {
MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("tests-surefire-suffix")).setGoals("clean test-compile surefire:test -Dsurefire.reportNameSuffix=Run1", "test-compile surefire:test -Dsurefire.reportNameSuffix=Run2", "sonar:sonar");
orchestrator.executeBuild(build);
Map<String, Measure> measures = getMeasures("com.sonarsource.it.samples:tests-surefire-suffix", "tests", "test_errors", "test_failures", "skipped_tests", "test_execution_time", "test_success_density");
assertThat(parseInt(measures.get("tests").getValue())).isEqualTo(2);
assertThat(parseInt(measures.get("test_errors").getValue())).isEqualTo(0);
assertThat(parseInt(measures.get("test_failures").getValue())).isEqualTo(0);
assertThat(parseInt(measures.get("skipped_tests").getValue())).isEqualTo(2);
assertThat(parseInt(measures.get("test_execution_time").getValue())).isGreaterThan(0);
assertThat(parseDouble(measures.get("test_success_density").getValue())).isEqualTo(100.0);
}
use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JavaExtensionsTest method test.
@Test
public void test() {
MavenBuild build = MavenBuild.create(TestUtils.projectPom("java-extension")).setCleanSonarGoals().setProperty("sonar.profile", "java-extension");
orchestrator.executeBuild(build);
IssueClient issueClient = orchestrator.getServer().wsClient().issueClient();
List<Issue> issues = issueClient.find(IssueQuery.create().rules("java-extension:example").componentRoots("com.sonarsource.it.projects:java-extension")).list();
// We found issues so the extension rule was properly set.
assertThat(issues).hasSize(4);
issues = issueClient.find(IssueQuery.create().rules("java-extension:subscriptionexamplecheck").componentRoots("com.sonarsource.it.projects:java-extension")).list();
assertThat(issues).hasSize(3);
issues = issueClient.find(IssueQuery.create().rules("java-extension:subscriptionexampletestcheck").componentRoots("com.sonarsource.it.projects:java-extension")).list();
assertThat(issues).hasSize(1);
}
use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JaCoCoControllerTest method test_coverage_per_test_reuse_forks.
@Test
public void test_coverage_per_test_reuse_forks() throws Exception {
MavenBuild build = MavenBuild.create(TestUtils.projectPom("coverage_error")).setProperty("skipTests", "false").setProperty("javaPluginVersion", javaVersion).setGoals("org.jacoco:jacoco-maven-plugin:prepare-agent clean verify", "sonar:sonar").addArgument("-P coverage-per-test-forked");
BuildResult buildResult = orchestrator.executeBuildQuietly(build);
assertThat(buildResult.isSuccess()).isTrue();
}
use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JaCoCoControllerTest method test_error_thrown.
@Test
public void test_error_thrown() {
// We build the project with JunitListeners to get coverage but with no jacoco agent to let JaCoCoController throw NoClassDefFoundError
MavenBuild build = MavenBuild.create(TestUtils.projectPom("coverage_error")).setProperty("skipTests", "false").setProperty("javaPluginVersion", javaVersion).setGoals("clean", "package");
BuildResult buildResult = orchestrator.executeBuildQuietly(build);
assertThat(buildResult.isSuccess()).isFalse();
assertThat(buildResult.getLogs()).contains("JacocoControllerError");
}
use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JavaComplexityTest method analyzeProject.
@BeforeClass
public static void analyzeProject() {
orchestrator.resetData();
MavenBuild build = MavenBuild.create(TestUtils.projectPom("java-complexity")).setCleanSonarGoals().setProperty("sonar.dynamicAnalysis", "false").setProperty("sonar.java.binaries", "target").setProperty("sonar.profile", "java-complexity");
orchestrator.executeBuild(build);
}
Aggregations