在 GitHub 上并行运行测试不会为所有测试文件生成 Allure 报告。只为最后一个测试文件生成

问题描述 投票:0回答:1

当我在本地或按顺序在 GitHub 上运行这些测试时,它会生成 Allure 报告,但是当我使用三个不同的 GitHub 实例并行运行它时,它只会为最后执行的测试文件生成结果。

    name: PROD_ALLURE_REPORT
on:
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    env:
        STAGE_USER_NAME: ${{ secrets.STAGE_USER__EMAIL}}
        STAGE_USER_PASSWORD: ${{ secrets.STAGE_USER_PASSWORD}}

    strategy:
      matrix:
        node-version: [18.14.0]
        test-file:
                  - bprod.test.js
                  - login.test.js
                  - Facebook.test.js

      fail-fast: false
      max-parallel: 3   
    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - run: npm install
    - run: npm install jest puppeteer jest-puppeteer
    - run: npm install -g jest   
    - run: npm i jest-allure
    - run: npm i allure-commandline
    - run: npm install dotenv
    - run: npm install @babel/core @babel/preset-env babel-jest
    - name: Run Tests   
      id: build
      run: npx jest ${{ matrix.test-file }} jest --reporters default jest-allure --detectOpenHandles --forceExit --testTimeout=300000
      continue-on-error: true
   
    - run: npm run alluregenerate
    - name: Upload a Build Artifact
      if: always()
      uses: actions/upload-artifact@v2-preview
      with: 
          name: report-${{ github.run_number }}
          path: allure-report
github github-actions puppeteer allure jest-puppeteer
1个回答
0
投票

为工件命名时,选择一个不太含糊的名称 1 以免轻易冒为不同工件使用相同名称的风险。

例如,这可以通过使用矩阵上下文中的日期来实现:

    - name: Upload a Build Artifact
      if: always()
      uses: actions/upload-artifact@v2-preview
      with: 
          name: report-${{ github.run_number }}-${{ matrix.test-file }}
          path: allure-report

(神器名称附加

test-file
来自
matrix
上下文)

或者,给每个测试报告一个不同的名称,并使这些报告成为工件(例如 junit xml 文件),然后收集步骤获取所有报告并在所有报告上运行 allure(例如目录,c.f.1)。


  1. 每个工件都充当文件共享。在同一个工作流程中多次上传到同一个工件可以覆盖和追加已经上传的文件

    来自:上传到同一个工件 - 上传工件 - 动作

© www.soinside.com 2019 - 2024. All rights reserved.