SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

Azure Pipeline on Linux - run same Project Multiple times in same Job gives Generation Error not able to find **/*.feature files on the 2nd Task

Open chrisusher-instanda opened this issue 3 years ago • 6 comments

SpecFlow Version

3.9.74

Which test runner are you using?

NUnit

Test Runner Version Number

3.13.2

.NET Implementation

.NET 5.0

Project Format of the SpecFlow project

Sdk-style project format

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

TFS/VSTS/Azure DevOps – Task – PLEASE SPECIFY THE NAME OF THE TASK

SpecFlow Section in app.config or content of specflow.json

{ "language": { "feature": "en-gb" }, "stepAssemblies": [ ], "livingDocGenerator": { "enabled": true, "filePath": "TestExecution.json" } }

Issue Description

This issue is not happening all the time but has started happening more and more often in our Azure Pipelines.

We have a Specflow Project we use multiple times in the same Job, just run with different --filter parameters

Pipeline YAML

I.e.

  • task: DotNetCoreCLI@2 displayName: Run Docker Container Tests inputs: command: test projects: TestProjectName/TestProjectName.csproj arguments: --filter "TestCategory!=wip&TestCategory=docker"
  • task: DotNetCoreCLI@2 displayName: Run API Tests inputs: command: test projects: TestProjectName/TestProjectName.csproj arguments: --filter "TestCategory!=wip&TestCategory!=docker"

The first Task always runs fine, but then the second Task fails with :

Error Log

See attached Error log as Markdown messes with the file search patterns 😦

SpecflowGeneratorIssue.log

Summary

The first Task was able to find the Feature Files and generate .feature.cs files successfully and Run Tests but the 2nd Time it doesn't work.

Steps to Reproduce

Define an Azure YAML Pipeline

  1. Runs on ubuntu-latest
  2. Has a Job which has two DotNetCoreCLI@2 Tasks using the Same Specflow Project (see issue description)
  3. Test Project is Net6.0

Link to Repro Project

No response

chrisusher-instanda avatar May 20 '22 08:05 chrisusher-instanda

You could try to add --no-build to the second task so that no build is triggered for it.

SabotageAndi avatar May 20 '22 12:05 SabotageAndi

@SabotageAndi Yes, we could, but wondering why multiple runs on the same job doesn't work without it. The feature files are there, as are the .feature.cs files already.

I can run tests many time on a dev machine with no complaints about not being able to find the feature files from the MSBuild Generation task.

chrisusher-instanda avatar May 20 '22 13:05 chrisusher-instanda

I'm getting this same issue running a build inside a docker container on Bamboo. I'm using 4.0.16-beta

**/*.feature : error : System.IO.DirectoryNotFoundException: Could not find a part of the path '/store/bamboo/agent-home/xml-data/build-dir/JOB/src/Tests/**/*.feature'. [/store/bamboo/agent-home/xml-data/build-dir/JOB/src/Tests/Tests.csproj]
**/*.feature : error :    at TechTalk.SpecFlow.Generator.FeatureFileInputExtensions.GetFeatureFileContentReader(FeatureFileInput featureFileInput, ProjectSettings projectSettings) [/store/bamboo/agent-home/xml-data/build-dir/JOB/src/Tests/Tests.csproj]

robertcoltheart avatar Oct 05 '22 00:10 robertcoltheart

Same problem on MacOS. Does anyone found a solution?

AvallaSD avatar Aug 29 '23 11:08 AvallaSD

I'm seeing similar errors that show deeper stack trace that make calls to Windows libraries (Microsoft.Win32.SafeHandle.Open), but it's running on linux.

GaTechThomas avatar Dec 08 '23 00:12 GaTechThomas