1.从github获取allure代码
https://github.com/allure-framework/allure2
2.安装gradle,用于打包jar
brew install gradle
3.配置gradle环境变量
vim ~/.bash_profile export GRADLE_HOME=/usr/local/Cellar/gradle/5.5.1 export PATH=${GRADLE_HOME}/bin
4.生效环境变量
source ~/.bash_profile
5.查看是否配置成功
gradle --version Welcome to Gradle 5.5.1! Here are the highlights of this release: - Kickstart Gradle plugin development with gradle init - Distribute organization-wide Gradle properties in custom Gradle distributions - Transform dependency artifacts on resolution For more details see https://docs.gradle.org/5.5.1/release-notes.html ------------------------------------------------------------ Gradle 5.5.1 ------------------------------------------------------------ Build time: 2019-07-10 20:38:12 UTC Revision: 3245f748c7061472da4dc184991919810f7935a5 Kotlin: 1.3.31 Groovy: 2.5.4 Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019 JVM: 1.8 OS:
6.进入目录修改srcmainjavaioqametaalluresummary中的SummaryPlugin.java
setReportName中参数修改成测试报告名称即可
/Users/admin/Downloads/allure2-master/allure-generator/
/* * Copyright 2019 Qameta Software OÜ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.qameta.allure.summary; import io.qameta.allure.CommonJsonAggregator; import io.qameta.allure.Constants; import io.qameta.allure.core.LaunchResults; import io.qameta.allure.entity.GroupTime; import io.qameta.allure.entity.Statistic; import java.util.List; /** * Plugins generates Summary widget. * * @since 2.0 */ public class SummaryPlugin extends CommonJsonAggregator { /** * Name of the json file. */ protected static final String JSON_FILE_NAME = "summary.json"; public SummaryPlugin() { super(Constants.WIDGETS_DIR, JSON_FILE_NAME); } @Override protected SummaryData getData(final List<LaunchResults> launches) { final SummaryData data = new SummaryData() .setStatistic(new Statistic()) .setTime(new GroupTime()) .setReportName("接口自动化测试报告"); launches.stream() .flatMap(launch -> launch.getResults().stream()) .forEach(result -> { data.getStatistic().update(result); data.getTime().update(result); }); return data; } }
7.执行gradle build(要用梯子不然构建不成功,这有点坑)
admin:allure-generator admin$ gradle build > Task :allure-generator:buildWeb > allure-generator@1.0.0 build /Users/admin/Downloads/allure2-master/allure-generator > npm run webpack:prod > allure-generator@1.0.0 webpack:prod /Users/admin/Downloads/allure2-master/allure-generator > npm run cleanup && npm run webpack:prod:main > allure-generator@1.0.0 cleanup /Users/admin/Downloads/allure2-master/allure-generator > rimraf build/www > allure-generator@1.0.0 webpack:prod:main /Users/admin/Downloads/allure2-master/allure-generator > npm run webpack -- --config webpack/webpack.prod.js --profile > allure-generator@1.0.0 webpack /Users/admin/Downloads/allure2-master/allure-generator > node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js "--config" "webpack/webpack.prod.js" "--profile" Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` Hash: 5afdb7cecc3130013cde Version: webpack 4.28.4 Time: 21998ms Built at: 2019-08-09 17:47:58 Asset Size Chunks Chunk Names app.js 660 KiB 0 [emitted] [big] main favicon.ico 57 bytes [emitted] styles.css 1.47 MiB 0 [emitted] [big] main Entrypoint main [big] = styles.css app.js [8] ./src/main/javascript/helpers/t.js 149 bytes {0} [built] [] 536ms -> [] 4885ms -> factory:903ms building:5534ms dependencies:1188ms = 13046ms [17] ./src/main/javascript/utils/translation.js + 15 modules 79.4 KiB {0} [built] | ./src/main/javascript/utils/translation.js 1.09 KiB [built] | [] 536ms -> [] 4885ms -> factory:903ms building:5534ms dependencies:1188ms = 13046ms | + 15 hidden modules [19] ./src/main/javascript/utils/settings.js 127 bytes {0} [built] [] 536ms -> [] 4885ms -> factory:40ms building:821ms dependencies:2343ms = 8625ms [26] ./src/main/javascript/utils/settingsFactory.js + 1 modules 5.31 KiB {0} [built] | ./src/main/javascript/utils/settingsFactory.js 3.91 KiB [built] | [] 536ms -> [] 4885ms -> factory:40ms building:821ms dependencies:2343ms = 8625ms | ./src/main/javascript/data/localstorage/LocalStorageModel.js 1.38 KiB [built] | [] 536ms -> [] 4885ms -> [] 861ms -> factory:847ms building:899ms dependencies:426ms = 8454ms [111] ./src/main/javascript/styles.scss 39 bytes {0} [built] [] 536ms -> [] 4885ms -> factory:903ms building:5534ms dependencies:1188ms = 13046ms [155] ./node_modules/file-loader/dist/cjs.js?name=favicon.ico!./src/main/javascript/favicon.ico 57 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [156] ./src/main/javascript/blocks/arrow/styles.scss 39 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [157] ./src/main/javascript/blocks/executor-icon/styles.scss 39 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [158] ./src/main/javascript/blocks/status-details/styles.scss 39 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [159] ./src/main/javascript/blocks/table/styles.scss 39 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [160] ./src/main/javascript/blocks/tabs/styles.scss 39 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [161] ./src/main/javascript/blocks/pane/styles.scss 39 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [182] ./src/main/javascript/plugins/tab-category/index.js 525 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [183] ./src/main/javascript/plugins/tab-suites/index.js 502 bytes {0} [built] [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms [197] ./src/main/javascript/index.js + 448 modules 530 KiB {0} [built] | ./src/main/javascript/index.js 1.41 KiB [built] | factory:50ms building:486ms = 536ms | ./src/main/javascript/app.js 1.8 KiB [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/pluginApi.js 878 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/default/index.js 271 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/tab-graph/index.js 211 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/tab-timeline/index.js 515 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-status/index.js 113 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-severity/index.js 115 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-duration/index.js 117 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-duration-trend/index.js 219 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-retry-trend/index.js 207 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-categories-trend/index.js 227 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-summary/index.js 115 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-history-trend/index.js 306 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | ./src/main/javascript/plugins/widget-suites/index.js 237 bytes [built] | [] 536ms -> factory:680ms building:4205ms dependencies:732ms = 6153ms | + 434 hidden modules + 226 hidden modules WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). This can impact web performance. Assets: styles.css (1.47 MiB) app.js (660 KiB) WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. Entrypoints: main (2.11 MiB) styles.css app.js WARNING in webpack performance recommendations: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application. For more info visit https://webpack.js.org/guides/code-splitting/ > Task :allure-generator:pmdMain This analysis could be faster, please consider using Incremental Analysis: https://pmd.github.io/pmd-6.11.0/pmd_userdocs_incremental_analysis.html Error during type resolution due to: java.lang.NoClassDefFoundError: com/opencsv/bean/MappingStrategy Error during type resolution due to: java.lang.NoClassDefFoundError: com/opencsv/bean/MappingStrategy > Task :allure-generator:compileTestJava /Users/admin/Downloads/allure2-master/allure-generator/src/test/java/io/qameta/allure/allure2/Allure2PluginTest.java:42: 警告: [deprecation] io.qameta.allure中的AllureUtils已过时 import static io.qameta.allure.AllureUtils.generateTestResultContainerName; ^ /Users/admin/Downloads/allure2-master/allure-generator/src/test/java/io/qameta/allure/allure2/Allure2PluginTest.java:43: 警告: [deprecation] io.qameta.allure中的AllureUtils已过时 import static io.qameta.allure.AllureUtils.generateTestResultName; ^ /Users/admin/Downloads/allure2-master/allure-generator/src/test/java/io/qameta/allure/allure1/Allure1PluginTest.java:299: 警告: [unchecked] 对于类型为Function<Parameter,?>[]的 varargs 参数, 泛型数组创建未经过检查 .extracting(Parameter::getName, Parameter::getValue) ^ /Users/admin/Downloads/allure2-master/allure-generator/src/test/java/io/qameta/allure/history/HistoryTrendPluginTest.java:141: 警告: [unchecked] 方法调用未经过检查: 将类 ArgumentCaptor中的方法 forClass应用到给定的类型 final ArgumentCaptor<List<HistoryTrendItem>> captor = ArgumentCaptor.forClass(List.class); ^ 需要: Class<S> 找到: Class<List> 其中, S,U是类型变量: S扩展已在方法 <U,S>forClass(Class<S>)中声明的U U扩展已在方法 <U,S>forClass(Class<S>)中声明的Object /Users/admin/Downloads/allure2-master/allure-generator/src/test/java/io/qameta/allure/history/HistoryTrendPluginTest.java:141: 警告: [unchecked] 未经检查的转换 final ArgumentCaptor<List<HistoryTrendItem>> captor = ArgumentCaptor.forClass(List.class); ^ 需要: ArgumentCaptor<List<HistoryTrendItem>> 找到: ArgumentCaptor 5 个警告 > Task :allure-generator:testWeb > allure-generator@1.0.0 test /Users/admin/Downloads/allure2-master/allure-generator > npm run lint > allure-generator@1.0.0 lint /Users/admin/Downloads/allure2-master/allure-generator > eslint --ignore-path=.gitignore ./src/main/javascript > Task :allure-generator:test io.qameta.allure.allure2.Allure2PluginTest > shouldProcessInvalidStatus() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldReadBeforesFromGroups() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldProcessNullStageTime() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldExcludeDuplicatedParams() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldProcessEmptyStatus() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldAddTestResultFormatLabel() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldDoNotOverrideAttachmentsForGroups() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldPickUpAttachmentsForAfters() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldProcessNullStatus() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldReadAftersFromGroups() PASSED io.qameta.allure.allure2.Allure2PluginTest > shouldPickUpAttachmentsForTestCase() PASSED io.qameta.allure.category.CategoriesPluginTest > shouldDefaultCategoriesToResults() PASSED io.qameta.allure.category.CategoriesPluginTest > shouldWork() PASSED io.qameta.allure.category.CategoriesPluginTest > shouldCreateTree() PASSED io.qameta.allure.category.CategoriesPluginTest > shouldSortByStartTimeAsc() PASSED io.qameta.allure.category.CategoriesPluginTest > flakyTestsCanBeAddedToCategory() PASSED io.qameta.allure.category.CategoriesPluginTest > shouldSetCustomCategoriesToResults() PASSED io.qameta.allure.retry.RetryPluginTest > shouldSkipHiddenResults() PASSED io.qameta.allure.retry.RetryPluginTest > shouldNotMarkLatestAsFlakyIfRetriesSkipped() PASSED io.qameta.allure.retry.RetryPluginTest > shouldNotMergeOtherTestResults() PASSED io.qameta.allure.retry.RetryPluginTest > shouldNotMarkLatestAsFlakyIfRetriesArePassed() PASSED io.qameta.allure.retry.RetryPluginTest > shouldMergeRetriesTestResults() PASSED io.qameta.allure.suites.SuitesPluginTest > shouldCreateTree() PASSED io.qameta.allure.suites.SuitesPluginTest > shouldSortByStartTimeAsc() PASSED io.qameta.allure.suites.SuitesPluginTest > shouldCreateCsvFile() PASSED io.qameta.allure.markdown.MarkdownAggregatorTest > shouldNotFailIfEmptyResults(Path) PASSED io.qameta.allure.markdown.MarkdownAggregatorTest > shouldSkipResultsWithNonEmptyDescriptionHtml(Path) PASSED io.qameta.allure.markdown.MarkdownAggregatorTest > shouldProcessDescription(Path) PASSED io.qameta.allure.markdown.MarkdownAggregatorTest > shouldSkipResultsWithEmptyDescription(Path) PASSED io.qameta.allure.idea.IdeaLinksPluginTest > shouldExportTestResultToJira() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldReadTestSuiteXml() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldExcludeDuplicatedParams() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldCopyLabelsFromSuite() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldAddTestResultFormatLabel() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldReadTestSuiteJson() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldNotFailIfSuiteTitleNotExists() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldProcessEmptyOrNullStatus() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldReadPropertiesFile() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldGenerateDifferentHistoryIdForParameterizedTests() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldProcessNullParameters() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldNotFailIfNoResultsDirectory() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldSetFlakyFromLabel() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldUseTestClassLabelForPackage() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldReadAttachments() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldUseTestClassLabelForFullName() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldBeAbleToSpecifyHistoryIdViaLabel() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldProcessEmptyLists() PASSED io.qameta.allure.allure1.Allure1PluginTest > shouldGetSuiteTitleIfExists() PASSED io.qameta.allure.history.HistoryPluginTest > shouldHasFlakyMark() PASSED io.qameta.allure.history.HistoryPluginTest > shouldHasNewFailedMark() PASSED io.qameta.allure.history.HistoryTrendPluginTest > shouldReadOldData(Path) PASSED io.qameta.allure.history.HistoryTrendPluginTest > shouldProcessNullBuildOrder() PASSED io.qameta.allure.history.HistoryTrendPluginTest > shouldGetData() PASSED io.qameta.allure.history.HistoryTrendPluginTest > shouldAggregateForEmptyReport(Path) PASSED io.qameta.allure.history.HistoryTrendPluginTest > shouldProcessCorruptedData(Path) PASSED io.qameta.allure.history.HistoryTrendPluginTest > shouldReadNewData(Path) PASSED io.qameta.allure.history.HistoryTrendPluginTest > shouldFindLatestExecutor() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetCategoriesTrendJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateCategoriesJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetEnvironmentJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetStatusJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetDurationJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateXunitJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetLaunchJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateMail() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetExecutorsJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateTestCases() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateHistory() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetCategoriesJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateIndexHtml() PASSED io.qameta.allure.ReportGeneratorTest > shouldWriteReportStatic() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetSeverityJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetHistoryTrendJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetSummaryJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetDurationTrendJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateTimelineJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateAttachments() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetSuitesJson() PASSED io.qameta.allure.ReportGeneratorTest > shouldGenerateWidgetRetryTrendJson() PASSED io.qameta.allure.EmptyResultsTest > shouldAllowNonExistsResultsDirectory(Path) PASSED io.qameta.allure.EmptyResultsTest > shouldAllowRegularFileAsResultsDirectory(Path) PASSED io.qameta.allure.EmptyResultsTest > shouldAllowEmptyResultsDirectory(Path) PASSED io.qameta.allure.environment.Allure1EnvironmentPluginTest > shouldStackParameterValues() PASSED io.qameta.allure.environment.Allure1EnvironmentPluginTest > shouldReadEnvironmentXml() PASSED io.qameta.allure.environment.Allure1EnvironmentPluginTest > shouldReadEnvironmentProperties() PASSED io.qameta.allure.prometheus.PrometheusMetricLineTest > shouldReturnMetric(String, String)[1] PASSED io.qameta.allure.prometheus.PrometheusMetricLineTest > shouldReturnMetric(String, String)[2] PASSED Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.5.1/userguide/command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 2m 42s 21 actionable tasks: 16 executed, 5 up-to-date
8.进入
/Users/admin/Downloads/allure2-master/allure-generator/build/libs
将刚刚打包生成的allure-generator-2.10.0-SNAPSHOT.jar重命名allure-generator-2.10.0.jar
9.将重命名好后的jar放在以下目录中并覆盖之前的jar
/usr/local/Cellar/allure/2.10.0/libexec/lib
10.查看执行的报告(此处省略了如何搭建allure生成测试报告内容),可见测试报告