private static void configureTestReports(Test testTask, Map<String, Object> properties) { File testResultsDir = testTask.getReports().getJunitXml().getDestination(); // do not set a custom test reports path if it does not exists, otherwise SonarQube will emit an error // do not set a custom test reports path if there are no files, otherwise SonarQube will emit a warning if (testResultsDir.isDirectory() && asList(testResultsDir.list()).stream().anyMatch(file -> TEST_RESULT_FILE_PATTERN.matcher(file).matches())) { appendProp(properties, "sonar.junit.reportPaths", testResultsDir); // For backward compatibility appendProp(properties, "sonar.junit.reportsPath", testResultsDir); appendProp(properties, "sonar.surefire.reportsPath", testResultsDir); } }
test.getReports().getJunitXml().setEnabled(true); test.getReports().getJunitXml().setDestination(junitPath(circleReportsDir, test.getPath())); }); proj.getTasks().withType(Checkstyle.class, checkstyle ->
@Override public void apply( Project project ) { project.getTasks().withType( Test.class ).configureEach( task -> { task.useJUnitPlatform(); task.testLogging( log -> log.info( info -> info.getEvents().add( TestLogEvent.PASSED ) ) ); task.reports( reports -> { reports.getJunitXml().setEnabled( true ); reports.getHtml().setEnabled( false ); } ); } ); } }
@Override void configure(Task task) { super.configure(task); Task prepareMonitorEnvTask = project.getTasks().findByName(AzurePlugin.PREPARE_MONITOR_ENV_TASK); Test t = (Test)task; t.setDescription("Test execution of the azureTest source set against production deployment."); t.dependsOn(prepareMonitorEnvTask); t.setClasspath(sourceSet.getRuntimeClasspath()); t.setTestClassesDirs(sourceSet.getOutput().getClassesDirs()); t.systemProperty("testEnvPath", azure.getMonitorEnvFile().get().getAsFile().getAbsolutePath()); t.setBinResultsDir(new File(project.getBuildDir(), "monitor-test-results/binary/test")); t.getReports().getHtml().setDestination(new File(project.getBuildDir(), "reports/monitor-test-results" )); t.getReports().getJunitXml().setDestination(new File(project.getBuildDir(), "monitor-test-results" )); } }
@Override public void apply( Project project ) { project.getPluginManager().apply( JavaLibraryPlugin.class ); DependencyHandler deps = project.getDependencies(); deps.add( TEST_IMPL, String.join( D, Junit.G, Junit.Api.A ) ); deps.add( TEST_IMPL, String.join( D, Junit.G, Junit.Param.A ) ); deps.add( TEST_RUN, String.join( D, Junit.G, Junit.Engine.A ) ); deps.add( TEST_IMPL, String.join( D, AssertJ.G, AssertJ.A ) ); project.getTasks().withType( Test.class ).configureEach( task -> { task.useJUnitPlatform(); task.testLogging( log -> log.info( info -> info.getEvents().add( TestLogEvent.PASSED ) ) ); task.reports( reports -> { reports.getJunitXml().setEnabled( true ); reports.getHtml().setEnabled( false ); } ); } ); } }
@Override public void apply( Project project ) { project.getPluginManager().apply( JavaLibraryPlugin.class ); DependencyHandler deps = project.getDependencies(); deps.add( TEST_IMPL, String.join( D, Junit.G, Junit.Api.A ) ); deps.add( TEST_IMPL, String.join( D, Junit.G, Junit.Param.A ) ); deps.add( TEST_RUN, String.join( D, Junit.G, Junit.Engine.A ) ); deps.add( TEST_IMPL, String.join( D, AssertJ.G, AssertJ.A ) ); project.getTasks().withType( Test.class ).configureEach( task -> { task.useJUnitPlatform(); task.testLogging( log -> log.info( info -> info.getEvents().add( TestLogEvent.PASSED ) ) ); task.reports( reports -> { reports.getJunitXml().setEnabled( true ); reports.getHtml().setEnabled( false ); } ); } ); project.getTasks().withType( JavaCompile.class ).configureEach( task -> { CompileOptions options = task.getOptions(); options.setAnnotationProcessorGeneratedSourcesDirectory( Paths.get( "build/generated/src" ).toFile() ); options.getCompilerArgs().addAll( Arrays.asList( "-parameters", "-Xlint:deprecation" ) ); } ); } }
private static void configureTestReports(Test testTask, Map<String, Object> properties) { File testResultsDir = testTask.getReports().getJunitXml().getDestination(); // do not set a custom test reports path if it does not exists, otherwise SonarQube will emit an error // do not set a custom test reports path if there are no files, otherwise SonarQube will emit a warning if (testResultsDir.isDirectory() && asList(testResultsDir.list()).stream().anyMatch(file -> TEST_RESULT_FILE_PATTERN.matcher(file).matches())) { appendProp(properties, "sonar.junit.reportPaths", testResultsDir); // For backward compatibility appendProp(properties, "sonar.junit.reportsPath", testResultsDir); appendProp(properties, "sonar.surefire.reportsPath", testResultsDir); } }