Forum Discussion
Zaher79
Sep 04, 2023Copper Contributor
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 wo...
Kidd_Ip
Sep 01, 2025MVP
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.