【问题标题】:How to run Specflow test cases in pipeline of Gitlab for CI/CD implementaiton如何在 Gitlab 的管道中运行 Specflow 测试用例以实现 CI/CD
【发布时间】:2022-01-14 05:46:45
【问题描述】:

我想实施 CI/CD,以便每当开发团队在其构建中提交任何更改时,我的整个自动化套件都会在构建和部署之前运行。

我在 GitLab 中有 yml 文件,在 Visual Studio 中有自动化测试用例脚本(C# 中的 Specflow 框架)。

请在下面找到 yml 文件:

demo_job_1:
     stage: test
     tags:
       - win
     script: 
       - echo "Test 1 started"
       - '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform\vstest.console.exe /ProjName.dll"'
       - '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\MSTest /testcontainer:D:\Users\username\source\repos\Project\ProjName\bin\Debug\netcoreapp3.1\ProjName.dll"'
       - "D:\Users\username\source\repos\Project\ProjName\ProjName.sln\Test\TestFeature1.csproj"'

但是我的工作没有实际执行项目中的任何测试用例就通过了

Visual Studio 中的文件夹结构:

我尝试对路径进行许多更改,但都没有成功。我是不是走错路了?谁能帮我解决这个问题?如果 yml 文件完全错误,那么有人可以指导我吗?提前致谢!!! :)

P.S:我在提交之前验证了 yml,ymlvalidator 将其显示为正确的 yml 文件。

【问题讨论】:

  • 谁能帮我解决这个问题?
  • 嗨,在你的脚本中我看到了路径“C:”。您要执行的文件必须在存储库 git 中。要拥有 Visual Studio 上下文,您必须指定关联图像
  • 感谢@Jean-Phi Baconnais 指导我。经过更多搜索,我终于找到了解决方案,我将其发布在下面

标签: gitlab continuous-integration gitlab-ci cicd gitlab-ci.yml


【解决方案1】:
demo_job_1:
     stage: test

     tags:
       - tags
       
       
     script:
       - Root dir location path
       - 'dotnet restore <path to the ProjName.sln>'
       - 'dotnet msbuild <path to the ProjName.sln>'
       - 'dotnet test <path to the ProjName.sln>'

希望这对其他人也有帮助!!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 2022-08-11
    • 1970-01-01
    • 2018-10-17
    • 2020-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多