import org.sonar.api.batch.SensorContext;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
+import org.sonar.api.resources.Java;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.JavaPackage;
import org.sonar.api.resources.Project;
import java.net.URISyntaxException;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyDouble;
import static org.mockito.Matchers.anyString;
sensor = new CoberturaSensor();
}
+ @Test
+ public void shouldNotAnalyseIfNoJavaProject() {
+ Project project = mock(Project.class);
+ when(project.getLanguageKey()).thenReturn("php");
+ when(project.getAnalysisType()).thenReturn(Project.AnalysisType.DYNAMIC);
+ assertFalse(sensor.shouldExecuteOnProject(project));
+ }
+
+ @Test
+ public void shouldNotAnalyseIfStaticAnalysis() {
+ Project project = mock(Project.class);
+ when(project.getLanguageKey()).thenReturn(Java.KEY);
+ when(project.getAnalysisType()).thenReturn(Project.AnalysisType.STATIC);
+ assertFalse(sensor.shouldExecuteOnProject(project));
+ }
+
+ @Test
+ public void shouldAnalyseIfReuseDynamicReports() {
+ Project project = mock(Project.class);
+ when(project.getLanguageKey()).thenReturn(Java.KEY);
+ when(project.getAnalysisType()).thenReturn(Project.AnalysisType.REUSE_REPORTS);
+ assertThat(sensor.shouldExecuteOnProject(project), is(true));
+ }
+
@Test
public void shouldNotFailIfReportNotSpecifiedOrNotFound() {
ProjectFileSystem pfs = mock(ProjectFileSystem.class);