Allure Report 生成器使用教程
1、项目介绍
Allure Report 是一个灵活的、轻量级的测试报告工具,能够为测试结果生成清晰、有吸引力的报告。simple-elf/allure-report-action
是一个 GitHub Action,用于在 GitHub 工作流中自动生成 Allure 报告,并支持历史报告的保留。
2、项目快速启动
安装步骤
在你的 GitHub 仓库中,创建或编辑 .github/workflows/ci.yml
文件,添加以下内容:
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Run tests
run: ./run-tests.sh
- name: Generate Allure Report
uses: simple-elf/allure-report-action@v1.9
with:
allure_results: 'allure-results'
allure_report: 'allure-report'
gh_pages: 'gh-pages'
allure_history: 'allure-history'
- name: Deploy report to GitHub Pages
uses: peaceiris/actions-gh-pages@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: 'allure-history'
配置说明
allure_results
: Allure 测试结果的目录路径。allure_report
: 生成的 Allure 报告的目录路径。gh_pages
: GitHub Pages 分支的目录路径。allure_history
: 历史报告的目录路径。
3、应用案例和最佳实践
应用案例
假设你有一个 Java 项目,使用 JUnit 进行测试。你可以通过以下步骤集成 Allure 报告:
- 在项目中添加 Allure 依赖。
- 配置测试运行器以生成 Allure 结果。
- 在 GitHub Actions 中使用上述配置生成和部署报告。
最佳实践
- 定期清理历史报告:为了节省存储空间,建议定期清理旧的历史报告。
- 自定义报告模板:根据项目需求,自定义 Allure 报告的模板和样式。
- 集成其他工具:将 Allure 报告与其他 CI/CD 工具集成,如 Jenkins、GitLab CI 等。
4、典型生态项目
Allure Report 可以与多种测试框架和工具集成,以下是一些典型的生态项目:
- JUnit:Java 项目的测试框架。
- pytest:Python 项目的测试框架。
- Selenium:Web 自动化测试工具。
- Jenkins:持续集成和持续部署工具。
通过这些集成,Allure Report 能够为不同类型的项目提供全面的测试报告解决方案。