diff --git a/.travis.yml b/.travis.yml index 989aafc..5979aac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: java jdk: - - oraclejdk8 + - oraclejdk11 - openjdk8 - + - openjdk11 diff --git a/pom.xml b/pom.xml index 2ec958b..8f4d4cf 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.naver.nid coverchecker - 1.3.3 + 1.3.4 jar diff --git a/src/main/java/com/naver/nid/cover/CoverChecker.java b/src/main/java/com/naver/nid/cover/CoverChecker.java index 998e67b..6b25f3d 100644 --- a/src/main/java/com/naver/nid/cover/CoverChecker.java +++ b/src/main/java/com/naver/nid/cover/CoverChecker.java @@ -29,10 +29,13 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; @Slf4j @RequiredArgsConstructor @@ -52,13 +55,15 @@ public CoverChecker(ObjectFactory objectManager) { objectManager.getReporter()); } - public void check(Parameter param) { + public boolean check(Parameter param) { try { RawDiffReader diffReader = createDiffReader(param); log.info("Check new line of code coverage by {}", coverageParser.getClass().getSimpleName()); - CompletableFuture> coverage = executeByBackground((Function>) coverageParser::parse) - .apply(param.getCoveragePath()); + CompletableFuture> coverage = param.getCoveragePath().stream() + .map(s -> executeByBackground((Function>) coverageParser::parse).apply(s)) + .reduce((f1, f2) -> f1.thenCombine(f2, (r1, r2) -> Stream.concat(r1.stream(), r2.stream()).collect(Collectors.toList()))) + .orElseThrow(() -> new IllegalStateException("No Coverage Report")); log.info("read diff by {}", diffReader.getClass().getSimpleName()); CompletableFuture> diff = executeByBackground(diffParser::parse) @@ -69,12 +74,14 @@ public void check(Parameter param) { reporter.report(check); log.info("check result {}", check.result()); + return true; } catch (Exception e) { NewCoverageCheckReport failResult = NewCoverageCheckReport.builder() .error(e) .build(); reporter.report(failResult); + return false; } } diff --git a/src/main/java/com/naver/nid/cover/checker/NewCoverageChecker.java b/src/main/java/com/naver/nid/cover/checker/NewCoverageChecker.java index 07cf10a..da69f2d 100644 --- a/src/main/java/com/naver/nid/cover/checker/NewCoverageChecker.java +++ b/src/main/java/com/naver/nid/cover/checker/NewCoverageChecker.java @@ -28,15 +28,20 @@ import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** - * diff 정보와 coverage report를 이용해 신규 코드에 대한 커버리지를 측정 + *

코드의 변경점과 coverage 리포트를 이용해 신규 코드에 대한 커버리지를 측정

+ * + *

NewCoverageChecker calculate test code coverage that updated.

*/ public class NewCoverageChecker { private static final Logger logger = LoggerFactory.getLogger(NewCoverageChecker.class); /** - * coverage report 와 diff 를 확인하여 신규 코드의 테스트 코드의 커버 정도를 확인한다. + *

coverage report 와 diff 를 확인하여 신규 코드의 테스트 코드의 커버 정도를 확인한다.

+ * + *

The method Check will calculate test coverage for new code for compare test coverage report and code diff.

* * @param coverage 파일 커버리지 리포트 결과 * @param diff 구 버전 파일과 신 버전 파일의 차이 @@ -46,35 +51,22 @@ public class NewCoverageChecker { */ public NewCoverageCheckReport check(List coverage, List diff, int threshold, int fileThreshold) { Map> diffMap = diff.stream() - .filter(d -> !d.getFileName().startsWith("src/test/java/")) - .filter(d -> d.getFileName().endsWith(".java")) + .filter(d -> !d.getFileName().startsWith("src/test")) .filter(d -> !d.getDiffSectionList().isEmpty()) .peek(d -> logger.debug("diff file {}", d.getFileName())) - .peek(d -> d.setFileName(d.getFileName().replaceFirst("src/main/java/", ""))) .collect(Collectors.toMap(Diff::getFileName , d -> d.getDiffSectionList().stream() .flatMap(s -> s.getLineList().stream()) .filter(l -> l.getType() == ModifyType.ADD) .collect(Collectors.toList()) - , (u1, u2) -> { - ArrayList diffs = new ArrayList<>(); - diffs.addAll(u1); - diffs.addAll(u2); - - return diffs; - })); + , (u1, u2) -> Stream.concat(u1.stream(), u2.stream()).collect(Collectors.toList()))); + // TODO redesign for multi module Map> coverageMap = coverage.stream() .peek(r -> logger.debug("file coverage {}", r.getFileName())) .collect(Collectors.toMap(FileCoverageReport::getFileName , FileCoverageReport::getLineCoverageReportList - , (u1, u2) -> { - ArrayList diffs = new ArrayList<>(); - diffs.addAll(u1); - diffs.addAll(u2); - - return diffs; - })); + , (u1, u2) -> Stream.concat(u1.stream(), u2.stream()).collect(Collectors.toList()))); NewCoverageCheckReport result = combine(coverageMap, diffMap); @@ -96,11 +88,23 @@ private NewCoverageCheckReport combine(Map> cov int coveredLineCount = 0; Set files = new HashSet<>(coverageReport.keySet()); - files.retainAll(newCodeLines.keySet()); List coveredFileList = new ArrayList<>(); for (String file : files) { - List diffList = newCodeLines.get(file); + // TODO 다른 모듈의 동일 패키지 동일 파일 이름일 경우에 대한 처리 필요 + + // 코드 커버리지의 끝 경로가 같은 경우에 대해 검색 + List diffList = newCodeLines.entrySet().stream() + .filter(e -> e.getKey().endsWith(file)) + .findFirst() + .map(Map.Entry::getValue) + .orElse(Collections.emptyList()); + + if (diffList.isEmpty()) { + logger.debug("file({}) is not changed", file); + continue; + } + List lineCoverageReports = coverageReport.get(file); logger.debug("check file {}", file); diff --git a/src/main/java/com/naver/nid/cover/util/Parameter.java b/src/main/java/com/naver/nid/cover/util/Parameter.java index 3fe8d3d..d6053c9 100644 --- a/src/main/java/com/naver/nid/cover/util/Parameter.java +++ b/src/main/java/com/naver/nid/cover/util/Parameter.java @@ -19,6 +19,8 @@ import lombok.Getter; import lombok.ToString; +import java.util.List; + @Getter @ToString @Builder @@ -27,7 +29,7 @@ public class Parameter { private int fileThreshold; private String githubToken; private String diffPath; - private String coveragePath; + private List coveragePath; private String githubUrl; private String repo; private String diffType; diff --git a/src/main/java/com/naver/nid/cover/util/ParameterParser.java b/src/main/java/com/naver/nid/cover/util/ParameterParser.java index 33d05b1..8796a68 100644 --- a/src/main/java/com/naver/nid/cover/util/ParameterParser.java +++ b/src/main/java/com/naver/nid/cover/util/ParameterParser.java @@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory; import java.io.PrintWriter; +import java.util.Arrays; public class ParameterParser { private static final Logger logger = LoggerFactory.getLogger(ParameterParser.class); @@ -53,7 +54,7 @@ public Parameter getParam(String... commandArgs) { .fileThreshold(getFileThreshold(cmd)) .githubToken(cmd.getOptionValue("g")) .diffPath(cmd.getOptionValue("d")) - .coveragePath(cmd.getOptionValue("c")) + .coveragePath(Arrays.asList(cmd.getOptionValues("c"))) .githubUrl(cmd.getOptionValue("u", IGitHubConstants.HOST_API)) .repo(cmd.getOptionValue("r")) .diffType(cmd.getOptionValue("diff-type")) @@ -86,62 +87,66 @@ private String getPrNumber(CommandLine cmd) { private Options executeOption() { Options commandOptions = new Options(); - Option diffPath = new Option("d", DIFF_OPTION, true, "diff file path(absolute recommend)"); - commandOptions.addOption(diffPath); + commandOptions.addOption(Option.builder("d") + .longOpt(DIFF_OPTION) + .hasArg() + .desc("diff file path(absolute recommend)") + .build()); - Option githubToken = new Option("g", GITHUB_TOKEN_OPTION, true, "github oauth token"); - githubToken.setRequired(true); - commandOptions.addOption(githubToken); + commandOptions.addOption(Option.builder("dt") + .longOpt("diff-type") + .hasArg() + .desc("diff type (github | file)") + .build()); + + commandOptions.addOption(Option.builder("g") + .longOpt(GITHUB_TOKEN_OPTION) + .required() + .hasArg() + .desc("github oauth token") + .build()); - Option githubUrl = Option.builder("u") - .desc("The url when you working on github enterprise url. default is api.github.com").hasArg() + commandOptions.addOption(Option.builder("u") .longOpt("github-url") - .build(); - commandOptions.addOption(githubUrl); + .hasArg() + .desc("The url when you working on github enterprise url. default is api.github.com") + .build()); - Option githubPrNum = Option.builder("p") - .desc("github pr number").hasArg() + commandOptions.addOption(Option.builder("p") .longOpt("pr") - .build(); - commandOptions.addOption(githubPrNum); + .hasArg() + .desc("github pr number") + .build()); - Option githubRepo = Option.builder("r").required() - .desc("github repo").hasArg() + commandOptions.addOption(Option.builder("r").required() .longOpt("repo") - .build(); - commandOptions.addOption(githubRepo); - - Option thresholdOption = Option.builder("t").required() - .desc("coverage pass threshold").hasArg() - .longOpt(THRESHOLD_OPTION).type(Integer.class) - .build(); - commandOptions.addOption(thresholdOption); + .hasArg() + .desc("github repo") + .build()); - Option coverReportPath = Option.builder("c") - .longOpt(COVERAGE_PATH_OPTION).hasArg() + commandOptions.addOption(Option.builder("c") + .longOpt(COVERAGE_PATH_OPTION) + .hasArg() .required() - .desc("coverage report path(absolute recommend)").build(); - commandOptions.addOption(coverReportPath); + .desc("coverage report path(absolute recommend)") + .build()); - Option coverReportType = Option.builder(COVERAGE_TYPE_OPTION) + commandOptions.addOption(Option.builder(COVERAGE_TYPE_OPTION) .hasArg() .desc("coverage report type (jacoco | cobertura) default is jacoco") - .build(); - commandOptions.addOption(coverReportType); + .build()); - Option fileThresholdOption = Option.builder("ft") - .longOpt("file-threshold") + commandOptions.addOption(Option.builder("t").required() + .longOpt(THRESHOLD_OPTION).type(Integer.class) .hasArg() - .desc("coverage report type (jacoco | cobertura) default is jacoco") - .build(); - commandOptions.addOption(fileThresholdOption); + .desc("coverage pass threshold") + .build()); - Option diffType = Option.builder("dt") - .longOpt("diff-type") + commandOptions.addOption(Option.builder("ft") + .longOpt("file-threshold") .hasArg() - .desc("diff type (github | file)") - .build(); - commandOptions.addOption(diffType); + .desc("coverage report type (jacoco | cobertura) default is jacoco") + .build()); return commandOptions; } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index db4c681..7a44aab 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,10 +1,6 @@ - - - %d{HH:mm:ss.SSS} [%thread] %-5level [%file:%line] %msg%n - - + diff --git a/src/main/resources/pattern.xml b/src/main/resources/pattern.xml new file mode 100644 index 0000000..8b2fcf0 --- /dev/null +++ b/src/main/resources/pattern.xml @@ -0,0 +1,8 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level \(%file:%line\) %msg%n + + + \ No newline at end of file diff --git a/src/test/java/com/naver/nid/cover/CoverCheckerTest.java b/src/test/java/com/naver/nid/cover/CoverCheckerTest.java index 77dab5a..5eafe7b 100644 --- a/src/test/java/com/naver/nid/cover/CoverCheckerTest.java +++ b/src/test/java/com/naver/nid/cover/CoverCheckerTest.java @@ -15,6 +15,7 @@ import com.naver.nid.cover.parser.diff.model.Line; import com.naver.nid.cover.parser.diff.model.ModifyType; import com.naver.nid.cover.reporter.Reporter; +import com.naver.nid.cover.reporter.console.ConsoleReporter; import com.naver.nid.cover.util.Parameter; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -27,6 +28,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; @@ -37,8 +39,7 @@ class CoverCheckerTest { @Mock private GithubPullRequestManager manager; - @Mock - private Reporter reporter; + private Reporter reporter = new ConsoleReporter(); @Mock private DiffParser diffParser; @@ -61,7 +62,8 @@ public void testCheck() { , Line.builder().lineNumber(2).type(ModifyType.ADD).build()); List diffSectionList = Collections.singletonList(DiffSection.builder().lineList(lines).build()); - Stream diffStream = Stream.of(Diff.builder().fileName("test.java").diffSectionList(diffSectionList).build()); + Stream diffStream = Stream.of(Diff.builder().fileName("test.java").diffSectionList(diffSectionList).build(), + Diff.builder().fileName("test2.java").diffSectionList(diffSectionList).build()); LineCoverageReport lineCoverageReport = new LineCoverageReport(); @@ -76,7 +78,12 @@ public void testCheck() { fileCoverageReport.setType("java"); fileCoverageReport.setFileName("test.java"); fileCoverageReport.setLineCoverageReportList(Arrays.asList(lineCoverageReport, lineCoverageReport2)); - List coverage = Collections.singletonList(fileCoverageReport); + FileCoverageReport fileCoverageReport2 = new FileCoverageReport(); + fileCoverageReport.setType("java"); + fileCoverageReport.setFileName("test2.java"); + fileCoverageReport.setLineCoverageReportList(Arrays.asList(lineCoverageReport, lineCoverageReport2)); + List coverageModule1 = Collections.singletonList(fileCoverageReport); + List coverageModule2 = Collections.singletonList(fileCoverageReport2); NewCoverageCheckReport newCoverageCheckReport = NewCoverageCheckReport.builder() .threshold(50) @@ -90,15 +97,18 @@ public void testCheck() { .build())) .build(); newCoverageCheckReport.setFileThreshold(30); + List coverageList = Stream.concat(coverageModule1.stream(), coverageModule2.stream()).collect(Collectors.toList()); List diffList = diffStream.collect(Collectors.toList()); doReturn(diffList.stream()).when(diffParser).parse(reader); - doReturn(coverage).when(coverageReportParser).parse((String) null); - doReturn(newCoverageCheckReport).when(checker).check(coverage, diffList, 50, 30); + doReturn(coverageModule1).when(coverageReportParser).parse("test-module1"); + doReturn(coverageModule2).when(coverageReportParser).parse("test-module2"); + doReturn(newCoverageCheckReport).when(checker).check(coverageList, diffList, 50, 30); Parameter param = Parameter.builder() .coveragePath(null) .diffPath("/path") + .coveragePath(Arrays.asList("test-module1", "test-module2")) .coverageType("jacoco") .githubToken("token") .githubUrl("enterprise.github.com") @@ -110,10 +120,11 @@ public void testCheck() { .build(); doReturn(reader).when(coverChecker).createDiffReader(param); - coverChecker.check(param); + assertTrue(coverChecker.check(param), "Coverchecker must finish successfully"); verify(diffParser).parse(reader); - verify(coverageReportParser).parse((String) null); - verify(checker).check(coverage, diffList, 50, 30); + verify(coverageReportParser).parse("test-module1"); + verify(coverageReportParser).parse("test-module2"); + verify(checker).check(coverageList, diffList, 50, 30); } } \ No newline at end of file diff --git a/src/test/java/com/naver/nid/cover/checker/NewCoverageCheckerTest.java b/src/test/java/com/naver/nid/cover/checker/NewCoverageCheckerTest.java index 23888cb..3587ef4 100644 --- a/src/test/java/com/naver/nid/cover/checker/NewCoverageCheckerTest.java +++ b/src/test/java/com/naver/nid/cover/checker/NewCoverageCheckerTest.java @@ -19,47 +19,143 @@ class NewCoverageCheckerTest { - @Test - public void coverCheckTest() { - NewCoverageChecker checker = new NewCoverageChecker(); + @Test + public void coverCheckTest() { + NewCoverageChecker checker = new NewCoverageChecker(); - List lines = Arrays.asList( - Line.builder().lineNumber(1).type(ModifyType.ADD).build() - , Line.builder().lineNumber(2).type(ModifyType.ADD).build()); + List lines = Arrays.asList( + Line.builder().lineNumber(1).type(ModifyType.ADD).build() + , Line.builder().lineNumber(2).type(ModifyType.ADD).build()); - List diffSectionList = Collections.singletonList(DiffSection.builder().lineList(lines).build()); - List diffList = Collections.singletonList(Diff.builder().fileName("test.java").diffSectionList(diffSectionList).build()); + List diffSectionList = Collections.singletonList(DiffSection.builder().lineList(lines).build()); + List diffList = Collections.singletonList(Diff.builder().fileName("test.java").diffSectionList(diffSectionList).build()); - LineCoverageReport lineCoverageReport = new LineCoverageReport(); - lineCoverageReport.setStatus(CoverageStatus.COVERED); - lineCoverageReport.setLineNum(1); + LineCoverageReport lineCoverageReport = new LineCoverageReport(); + lineCoverageReport.setStatus(CoverageStatus.COVERED); + lineCoverageReport.setLineNum(1); - LineCoverageReport lineCoverageReport2 = new LineCoverageReport(); - lineCoverageReport2.setStatus(CoverageStatus.UNCOVERED); - lineCoverageReport2.setLineNum(2); + LineCoverageReport lineCoverageReport2 = new LineCoverageReport(); + lineCoverageReport2.setStatus(CoverageStatus.UNCOVERED); + lineCoverageReport2.setLineNum(2); - FileCoverageReport fileCoverageReport = new FileCoverageReport(); - fileCoverageReport.setType("java"); - fileCoverageReport.setFileName("test.java"); - fileCoverageReport.setLineCoverageReportList(Arrays.asList(lineCoverageReport, lineCoverageReport2)); - List coverage = Collections.singletonList(fileCoverageReport); + FileCoverageReport fileCoverageReport = new FileCoverageReport(); + fileCoverageReport.setType("java"); + fileCoverageReport.setFileName("test.java"); + fileCoverageReport.setLineCoverageReportList(Arrays.asList(lineCoverageReport, lineCoverageReport2)); + List coverage = Collections.singletonList(fileCoverageReport); - NewCoverageCheckReport newCoverageCheckReport = NewCoverageCheckReport.builder() - .threshold(60) - .totalNewLine(2) - .coveredNewLine(1) - .coveredFilesInfo( - Collections.singletonList(NewCoveredFile.builder() - .name("test.java") - .addedLine(2) - .addedCoverLine(1) - .build())) - .build(); + NewCoverageCheckReport newCoverageCheckReport = NewCoverageCheckReport.builder() + .threshold(60) + .totalNewLine(2) + .coveredNewLine(1) + .coveredFilesInfo( + Collections.singletonList(NewCoveredFile.builder() + .name("test.java") + .addedLine(2) + .addedCoverLine(1) + .build())) + .build(); - NewCoverageCheckReport check = checker.check(coverage, diffList, 60, 0); - assertEquals(newCoverageCheckReport, check); + NewCoverageCheckReport check = checker.check(coverage, diffList, 60, 0); + assertEquals(newCoverageCheckReport, check); - } + } + @Test + public void coverCheckTestForNonJava() { + NewCoverageChecker checker = new NewCoverageChecker(); + + List lines = Arrays.asList( + Line.builder().lineNumber(1).type(ModifyType.ADD).build() + , Line.builder().lineNumber(2).type(ModifyType.ADD).build()); + + List diffSectionList = Collections.singletonList(DiffSection.builder().lineList(lines).build()); + List diffList = Collections.singletonList(Diff.builder().fileName("test.kt").diffSectionList(diffSectionList).build()); + + + LineCoverageReport lineCoverageReport = new LineCoverageReport(); + lineCoverageReport.setStatus(CoverageStatus.COVERED); + lineCoverageReport.setLineNum(1); + + LineCoverageReport lineCoverageReport2 = new LineCoverageReport(); + lineCoverageReport2.setStatus(CoverageStatus.UNCOVERED); + lineCoverageReport2.setLineNum(2); + + FileCoverageReport fileCoverageReport = new FileCoverageReport(); + fileCoverageReport.setType("java"); + fileCoverageReport.setFileName("test.kt"); + fileCoverageReport.setLineCoverageReportList(Arrays.asList(lineCoverageReport, lineCoverageReport2)); + List coverage = Collections.singletonList(fileCoverageReport); + + NewCoverageCheckReport newCoverageCheckReport = NewCoverageCheckReport.builder() + .threshold(60) + .totalNewLine(2) + .coveredNewLine(1) + .coveredFilesInfo( + Collections.singletonList(NewCoveredFile.builder() + .name("test.kt") + .addedLine(2) + .addedCoverLine(1) + .build())) + .build(); + + NewCoverageCheckReport check = checker.check(coverage, diffList, 60, 0); + assertEquals(newCoverageCheckReport, check); + } + + @Test + public void coverCheckTestForMultiModule() { + NewCoverageChecker checker = new NewCoverageChecker(); + + List lines = Arrays.asList( + Line.builder().lineNumber(1).type(ModifyType.ADD).build() + , Line.builder().lineNumber(2).type(ModifyType.ADD).build()); + + List diffSectionList = Collections.singletonList(DiffSection.builder().lineList(lines).build()); + List diffList = Arrays.asList( + Diff.builder().fileName("Module1/src/main/kotlin/test.kt").diffSectionList(diffSectionList).build(), + Diff.builder().fileName("Module2/src/main/kotlin/test.kt").diffSectionList(diffSectionList).build()); + + + LineCoverageReport lineCoverageReport = new LineCoverageReport(); + lineCoverageReport.setStatus(CoverageStatus.COVERED); + lineCoverageReport.setLineNum(1); + + LineCoverageReport lineCoverageReport2 = new LineCoverageReport(); + lineCoverageReport2.setStatus(CoverageStatus.UNCOVERED); + lineCoverageReport2.setLineNum(2); + + FileCoverageReport fileCoverageReport = new FileCoverageReport(); + fileCoverageReport.setType("kt"); + fileCoverageReport.setFileName("Module1/src/main/kotlin/test.kt"); + fileCoverageReport.setLineCoverageReportList(Arrays.asList(lineCoverageReport, lineCoverageReport2)); + + FileCoverageReport fileCoverageReport2 = new FileCoverageReport(); + fileCoverageReport2.setType("kt"); + fileCoverageReport2.setFileName("Module2/src/main/kotlin/test.kt"); + fileCoverageReport2.setLineCoverageReportList(Arrays.asList(lineCoverageReport, lineCoverageReport2)); + + List coverage = Arrays.asList(fileCoverageReport, fileCoverageReport2); + + NewCoverageCheckReport newCoverageCheckReport = NewCoverageCheckReport.builder() + .threshold(60) + .totalNewLine(4) + .coveredNewLine(2) + .coveredFilesInfo( + Arrays.asList(NewCoveredFile.builder() + .name("Module2/src/main/kotlin/test.kt") + .addedLine(2) + .addedCoverLine(1) + .build(), + NewCoveredFile.builder() + .name("Module1/src/main/kotlin/test.kt") + .addedLine(2) + .addedCoverLine(1) + .build())) + .build(); + + NewCoverageCheckReport check = checker.check(coverage, diffList, 60, 0); + assertEquals(newCoverageCheckReport, check); + } } \ No newline at end of file diff --git a/src/test/java/com/naver/nid/cover/util/ParameterParserTest.java b/src/test/java/com/naver/nid/cover/util/ParameterParserTest.java index 3e976ee..33c8a6b 100644 --- a/src/test/java/com/naver/nid/cover/util/ParameterParserTest.java +++ b/src/test/java/com/naver/nid/cover/util/ParameterParserTest.java @@ -3,15 +3,17 @@ import org.eclipse.egit.github.core.client.IGitHubConstants; import org.junit.jupiter.api.Test; +import java.util.Arrays; + import static org.junit.jupiter.api.Assertions.*; class ParameterParserTest { @Test public void getParam() { - String param = "-c /path -d /path -t 50 -g github_token -r repo -p 3 -type cobertura --diff-type github"; + String param = "-c /path -c /path2 -d /path -t 50 -g github_token -r repo -p 3 -type cobertura --diff-type github"; Parameter parameter = new ParameterParser().getParam(param.split(" ")); - assertEquals("/path", parameter.getCoveragePath()); + assertEquals(Arrays.asList("/path", "/path2"), parameter.getCoveragePath()); assertEquals("/path", parameter.getDiffPath()); assertEquals(50, parameter.getThreshold()); assertEquals("github_token", parameter.getGithubToken()); diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml new file mode 100644 index 0000000..db91e72 --- /dev/null +++ b/src/test/resources/logback-test.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml deleted file mode 100644 index 5a2ba70..0000000 --- a/src/test/resources/logback.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level [%file:%line] %msg%n - - - - - - - \ No newline at end of file