@Test public void testShouldAnalyseReusedReports() throws Exception { conf.addProperty(GendarmeConstants.MODE, GendarmeSensor.MODE_REUSE_REPORT); conf.addProperty(GendarmeConstants.REPORTS_PATH_KEY, "**/*.xml"); initializeSensor(); GendarmeRunner runner = mock(GendarmeRunner.class); GendarmeCommandBuilder builder = GendarmeCommandBuilder.createBuilder(null, vsProject); builder.setExecutable(new File("FxCopCmd.exe")); when(runner.createCommandBuilder(eq(solution), any(VisualStudioProject.class))) .thenReturn(builder); PowerMockito.mockStatic(GendarmeRunner.class); when(GendarmeRunner.create(anyString(), anyString())).thenReturn(runner); File fakeReport = TestUtils.getResource("/Sensor/FakeGendarmeConfigFile.xml"); PowerMockito.mockStatic(FileFinder.class); when(FileFinder.findFiles(solution, vsProject, "**/*.xml")) .thenReturn(Lists.newArrayList(fakeReport, fakeReport)); Project project = mock(Project.class); when(project.getName()).thenReturn("Project #1"); SensorContext context = mock(SensorContext.class); sensor.analyse(project, context); verify(resultParser, times(2)).parse(any(File.class)); }
@Test public void testShouldLaunchGendarme() throws Exception { GendarmeRunner runner = mock(GendarmeRunner.class); GendarmeCommandBuilder builder = GendarmeCommandBuilder.createBuilder(null, vsProject); builder.setExecutable(new File("Gendarme.exe")); when(runner.createCommandBuilder(eq(solution), any(VisualStudioProject.class))) .thenReturn(builder); PowerMockito.mockStatic(GendarmeRunner.class); when(GendarmeRunner.create(anyString(), anyString())).thenReturn(runner); Project project = mock(Project.class); when(project.getName()).thenReturn("Project #1"); SensorContext context = mock(SensorContext.class); sensor.analyse(project, context); verify(runner).execute(any(GendarmeCommandBuilder.class), eq(10)); }
@Test public void testLaunchGendarme() throws Exception { GendarmeSensor sensor = new GendarmeSensor.RegularGendarmeSensor( fileSystem, null, null, null, new CSharpConfiguration(new BaseConfiguration()), microsoftWindowsEnvironment); GendarmeRunner runner = mock(GendarmeRunner.class); GendarmeCommandBuilder builder = GendarmeCommandBuilder.createBuilder(solution, vsProject); builder.setExecutable(new File("gendarme.exe")); when(runner.createCommandBuilder(solution, vsProject)).thenReturn(builder); Project project = mock(Project.class); when(project.getName()).thenReturn("Project #1"); sensor.launchGendarme( project, runner, TestUtils.getResource("/Sensor/FakeGendarmeConfigFile.xml")); verify(runner).execute(any(GendarmeCommandBuilder.class), eq(10)); }