### Question:
JacocoReportTask extends AndroidVariantTask { @TaskAction public void generateReport() throws IOException { Set<File> coverageFiles = coverageDirectories .get() .getAsFileTree() .getFiles() .stream() .filter(File::isFile) .collect(Collectors.toSet()); if (coverageFiles.isEmpty()) { throw new IOException( String.format( "No coverage data to process in directories [%1$s]", coverageDirectories.getFiles())); } executor.submit( JacocoReportWorkerAction.class, workerConfiguration -> { workerConfiguration.setIsolationMode(IsolationMode.CLASSLOADER); workerConfiguration.classpath(jacocoClasspath.getFiles()); workerConfiguration.setParams( coverageFiles, getReportDir(), getClassFileCollection().getFiles(), getSourceFolders().getFiles(), getTabWidth(), getReportName()); }); } @Inject  JacocoReportTask(@NonNull WorkerExecutor executor); @Deprecated void setCoverageFile(File coverageFile); @InputFiles @Optional @Nullable BuildableArtifact getCoverageDirectories(); @OutputDirectory File getReportDir(); void setReportDir(File reportDir); @InputFiles BuildableArtifact getClassFileCollection(); @InputFiles FileCollection getSourceFolders(); String getReportName(); @Input void setReportName(String reportName); @InputFiles FileCollection getJacocoClasspath(); void setJacocoClasspath(FileCollection jacocoClasspath); @Input int getTabWidth(); void setTabWidth(int tabWidth); @TaskAction void generateReport();  }### Answer:
@Test public void sanityCheckReport() throws IOException, URISyntaxException { File coverageFile = copyResourceToFolder( "jacocoReport/com/android/tools/build/tests/myapplication/coverage.ec", mTemporaryFolder.newFolder()); File sourceRoot = setUpSourceDirectory(); File classDir = setUpClassDirectory(); File reportDir = mTemporaryFolder.newFolder(); JacocoReportTask.JacocoReportWorkerAction.generateReport( ImmutableList.of(coverageFile), reportDir, ImmutableList.of(classDir), ImmutableList.of(sourceRoot), 4, "debug"); File indexHtml = new File(reportDir, "index.html"); Document document = Jsoup.parse(indexHtml, Charsets.UTF_8.name(), indexHtml.getParentFile().toURI().toString()); Elements totals = document.select("td:contains(48 of 53)"); expect.that(totals).named("Total coverage table cell").hasSize(1); document = navigateTo( getLinkWithText(document, "com.android.tools.build.tests.myapplication")); getLinkWithText(document, "MainActivity.new View.OnClickListener() {...}"); expect.that(document.text()).doesNotContain("BuildConfig"); document = navigateTo(getLinkWithText(document, "MainActivity")); document = navigateTo(getLinkWithText(document, "doA()")); Elements covered = document.select("span.fc"); assertThat(covered).isNotEmpty(); assertThat(covered.get(0).text()).contains("Log.d(\"Test1\", \"Do a\");"); }