@Test public void testAnalyse() { parser = mock(CoverageResultParser.class); // create the parser before the sensor CoverageReportSensor sensor = buildSensor(); microsoftWindowsEnvironment.setTestExecutionDone(); File solutionDir = TestUtils.getResource("/Results/coverage/"); microsoftWindowsEnvironment.setWorkingDirectory(""); when(solution.getSolutionDir()).thenReturn(solutionDir); when(solution.getProject("MyAssembly")).thenReturn(vsProject1); List<FileCoverage> sourceFiles = new ArrayList<FileCoverage>(); List<ProjectCoverage> projects = new ArrayList<ProjectCoverage>(); ParserResult parserResult = new ParserResult(projects, sourceFiles); when(parser.parse(eq(project), any(File.class))).thenReturn(parserResult); ProjectCoverage projectCoverage = mock(ProjectCoverage.class); when(projectCoverage.getAssemblyName()).thenReturn("MyAssembly"); projects.add(projectCoverage); SensorContext context = mock(SensorContext.class); sensor.analyse(project, context); verify(projectCoverage).getFileCoverageCollection(); }
@Test public void testShouldNotExecuteOnProjectIfSkip() throws Exception { conf.setProperty(GallioConstants.MODE, CoverageReportSensor.MODE_SKIP); CoverageReportSensor sensor = buildSensor(); assertFalse(sensor.shouldExecuteOnProject(project)); }
@Test public void testShouldNotExecuteOnProjectIfTestProject() throws Exception { CoverageReportSensor sensor = buildSensor(); when(project.getName()).thenReturn("Project Test #2"); assertFalse(sensor.shouldExecuteOnProject(project)); }
@Test public void testShouldExecuteOnProject() throws Exception { CoverageReportSensor sensor = buildSensor(); assertTrue(sensor.shouldExecuteOnProject(project)); }