基于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