Skip to content

Latest commit

 

History

History
78 lines (63 loc) · 3.02 KB

coverageReport.md

File metadata and controls

78 lines (63 loc) · 3.02 KB

覆盖率报告生成


用途

基于jacoco,生成代码覆盖率报告。

功能清单

CoverageReport.generate
CoverageReport.genForMethodLink
CoverageReport.genForReportDiff

参数说明

参数 类型 必须 说明
execType ExecType 执行类型
projectRootPath String 项目根目录路径
currentBranch String 当前分支
compareBranch String 对比分支
currentCommit String 当前commit版本
compareCommit String 对比commit版本
currentTag String 当前tag
compareTag String 对比tag
gitParam GitParam git参数
excludes List 需要排除的包名
excludesMethod List 需要排除的方法名
excludeSubPkg List 需要排除的子工程
relationSubPkg List 关联的子工程
needUpdate Boolean 工程代码是否需要更新
title String 报告标题
execDataFile File exec文件
reportDirectory File 报告生成路径
reportType ReportType 默认html
projectList List 被分析的项目列表
methodInfos List 方法信息
reportDiffParam ReportDiffParam 基准和对比的exec文件信息

使用示例

ProjectFile projectFile= new ProjectFile(projectRootPath,classesDirectory,sourceDirectory);

projectList.add(projectFile);
ReportParam  reportParam=  new ReportParam(title, execDataPath, reportDirectoryPath, reportType, this.projectList);
reportParam.setReportDirectory(reportDirectory);

ProjectParam projectParam = new ProjectParam();
projectParam.setProjectRootPath(projectRootPath);
projectParam.setExecType(ExecType.BRANCH_DIFF);
projectParam.setCurrentBranch(currentBranch);
projectParam.setCompareBranch(compareBranch);

GitParam gitParam = new GitParam();
gitParam.setGitRepoDir(gitRepoDir);
gitParam.setGitAccessType(ACCESS_TOKEN);
gitParam.setGitAccessToken(gitAccessToken);
gitParam.setGitUser(gitUser);
gitParam.setGitPassword(gitPassword);
projectParam.setGitParam(gitParam);

try {
  IBundleCoverage iBundleCoverage =  CoverageReport.generate(reportParam,projectParam);
} catch (Exception e) {
  e.printStackTrace();
}

供参考单测:

CoverageOperateTest