Forum Discussion

Zaher79's avatar
Zaher79
Copper Contributor
Sep 04, 2023

Pipeline is running test cases twice after moving to new folder

Hi

I'm running test cases (written i SpecFlow/C#) on Azure Pipeline connected to an Azure agent on an on-premise PC.

I've recently moved out some feature-files (test cases) to a subfolder and it works great when i run locally. But when I run the same code in the pipeline the moved test cases are being run twice. I've disabled some test cases (by commenting out the content in the feature file) and run the pipeline, which strangely still running the disabled test case (but only once this time).

It seems that Azure uses some cashed data when running and doesn't really notice all committed changes.

Have any of you seen that problem before?

1 Reply

  • Try to fix by below:

     

    • Clean Build Output
      Add a step to delete the bin and obj folders before building:
    - script: |
        echo Cleaning old build artifacts...
        rd /s /q "$(Build.SourcesDirectory)\YourProject\bin"
        rd /s /q "$(Build.SourcesDirectory)\YourProject\obj"
      displayName: 'Clean build folders'

     

    • Enable Diagnostic Logging
      Set system.debug: true in your pipeline to get detailed logs and confirm which test assemblies are being picked up.
    • Use Explicit Test Filters
      In your VSTest task, use testSelector or testAssembly filters to narrow down exactly which tests should run:
    - task: VSTest@2
      inputs:
        testAssemblyVer2: '**\*Tests.dll'
        testFiltercriteria: 'FullyQualifiedName~YourNamespace'

     

    • Delete Old Feature Files
      Make sure any old .feature.cs files generated by SpecFlow are removed from the project if the corresponding .feature files were moved or deleted.
    • Check .csproj Includes
      Ensure your .csproj file doesn’t still include the old paths manually. Sometimes moved files are still referenced due to hardcoded paths.

Resources