Search code examples
gitlabcontinuous-integrationgitlab-cicicdgitlab-ci.yml

How to run Specflow test cases in pipeline of Gitlab for CI/CD implementaiton


I want to implement CI/CD so that whenever dev team commits any changes in their build then my whole automation suite runs before build and deployment.

I have yml file in GitLab and automated test case scripts in Visual Studio (Specflow framework in C#).

Please find below yml file:

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"'

But my job is passing without actually executing any of the test cases from the project

Folder structure in Visual studio: enter image description here

I tried to do many changes in the path but none worked. Am I entering the wrong path? Can anyone please help me with this? If the yml file is completely wrong then can someone please guide me in the same? Thanks in advance!!! :)

P.S: I had validated yml before committing it and ymlvalidator showed it as the correct yml file.


Solution

  • 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>'
    

    Hope this helps others too!!!