Scanner { void execute(List<InputFile> files) { ProgressReport progressReport = new ProgressReport("PHP analyzer progress", TimeUnit.SECONDS.toMillis(10)); execute(progressReport, files); } Scanner(SensorContext context);   }
@Test public void progress_report_should_be_stopped() { TestScanner scanner = new TestScanner(context); scanner.execute(progressReport, ImmutableList.of(PhpTestUtils.inputFile("empty.php"))); verify(progressReport).stop(); }
@Test public void cancelled_analysis() { Scanner scanner = new TestScanner(context); context.setCancelled(true); thrown.expectMessage("Analysis cancelled"); try { scanner.execute(progressReport, ImmutableList.of(PhpTestUtils.inputFile("empty.php"))); } finally { verify(progressReport).cancel(); verify(progressReport, never()).stop(); } }