@Test public void testToCommandForSolution() throws Exception { StyleCopCommandBuilder styleCopCommandBuilder = StyleCopCommandBuilder.createBuilder(solution); styleCopCommandBuilder.setDotnetSdkDirectory(new File("DotnetSdkDir")); styleCopCommandBuilder.setStyleCopFolder(new File("StyleCopDir")); styleCopCommandBuilder.setConfigFile( TestUtils.getResource("/Runner/Command/SimpleRules.StyleCop")); styleCopCommandBuilder.setReportFile(new File("target/sonar/report.xml")); Command command = styleCopCommandBuilder.toCommand(); assertThat(command.getExecutable(), endsWith("MSBuild.exe")); String[] commands = command.getArguments().toArray(new String[] {}); assertThat(commands[0], endsWith("solution")); assertThat(commands[1], is("/target:StyleCopLaunch")); assertThat(commands[2], is("/noconsolelogger")); assertThat(commands[3], endsWith("stylecop-msbuild.xml")); File report = new File("target/sonar/stylecop-msbuild.xml"); assertTrue(report.exists()); report.delete(); }
@Test(expected = IllegalStateException.class) public void testWithUnexistingStyleCopConfigFile() throws Exception { StyleCopCommandBuilder styleCopCommandBuilder = StyleCopCommandBuilder.createBuilder(solution); styleCopCommandBuilder.toCommand(); }