【问题标题】:Github Actions run Nunit Selenium tests questionGithub Actions 运行 Nunit Selenium 测试问题
【发布时间】:2021-06-25 20:30:09
【问题描述】:

我有一个包含 3 个项目的 Visual Studio 解决方案。这些是主要的 Web 应用程序项目、单元测试项目,最后是 Selenium、NUnit、SpecFlow 回归测试项目。

我正在尝试在 GitHub 操作中设置 CI/CD,到目前为止,我的 yaml 文件中有 2 个作业。

Job 1 针对 web 项目运行单元测试项目,并且通过了

  tests:        
    name:  Unit Testing
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2.1.0
      - run: dotnet test --no-build --verbosity normal

Job 2 构建 Web 项目

  build:
    name:  BuildProject
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 5.0.x
    - name: Restore dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --no-restore

我现在要做的是添加第三个作业,该作业将针对主 Web 项目运行 selenium 测试套件,但我不知道如何从 yaml 文件中运行它。

谁能给我指出一个好的步骤或示例。

干杯

凯夫

所以现在我添加了这个工作

regression:  
needs: tests 
name: Regression tests   
runs-on: windows-latest
steps:
  - uses: actions/checkout@v2.1.0
  - run: dotnet test SpiceTheWorld.Regression --no-restore --verbosity normal  

这似乎运行没有错误,但它在 20 秒内完成,在命令行上运行相同需要 40 秒,所以我不确定它是否真的在运行。

这是输出

【问题讨论】:

  • 你试过什么?你遇到了什么错误?你检查过这个吗:docs.specflow.org/projects/specflow/en/latest/Getting-Started/…
  • 不,那是解决方案中的回归项目名称
  • dotnet test SpiceTheWorld.Regression --no-build --verbosity normal --filter TestCategory=SpiceRegression 在命令行上工作正常
  • 详细详细地运行它并发布该步骤的完整日志。

标签: c# selenium nunit github-actions specflow


【解决方案1】:

感谢您的帮助。 我现在可以运行了,下面是脚本。

    name: Spicethedeploy
on:
  push:
    branches: [ development ]
  pull_request:
    branches: [ development ]
    
jobs:
  
  build:
    name:  Buildspice
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
      uses: actions/setup-dotnet@v1.7.2
      with:
        dotnet-version: ${{ matrix.dotnet-version }}
    - name: Install dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --configuration Release --no-restore
      
  unittests:      
    needs: build
    name:  Unit Testing
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
      uses: actions/setup-dotnet@v1.7.2
      with:
        dotnet-version: ${{ matrix.dotnet-version }}
    - name: Install dependencies
      run: dotnet restore
    - name: Unit Tests
      run: dotnet test SpiceTheWorld.Tests --no-restore --verbosity Minimal          
 
  regression:  
    needs: unittests 
    name: Regression
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
      uses: actions/setup-dotnet@v1.7.2
      with:
        dotnet-version: ${{ matrix.dotnet-version }}
    - name: Install dependencies
      run: dotnet restore
    - name: Regression tests 
      run: dotnet test SpiceTheWorld.Regression --no-restore --verbosity Minimal --filter TestCategory=SpiceRegression

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-30
    • 2022-01-17
    • 1970-01-01
    • 2021-10-03
    • 2021-03-20
    • 2021-04-23
    相关资源
    最近更新 更多