SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

[SpecFlow] System.UnauthorizedAccessException: Access to the path is denied in .NetCore in C#

Open F1WWFC23 opened this issue 2 years ago • 0 comments

SpecFlow Version

3.9.74

Which test runner are you using?

NUnit

Test Runner Version Number

3.13.3

.NET Implementation

.NET 5.0

Package References

<PackageReference Include="Appium.WebDriver" Version="4.4.0" /> <PackageReference Include="Azure.Core" Version="1.28.0" /> <PackageReference Include="DotNetSeleniumExtras.PageObjects" Version="3.11.0" /> <PackageReference Include="DotNetSeleniumExtras.PageObjects.Core" Version="4.3.0" /> <PackageReference Include="DotNetSeleniumExtras.WaitHelpers" Version="3.11.0" /> <PackageReference Include="ExtentReports" Version="4.1.0" /> <PackageReference Include="Faker.Data" Version="2.0.1" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> <PackageReference Include="ParkSquare.Testing.Helpers" Version="3.4.7" /> <PackageReference Include="Polly" Version="7.2.3" /> <PackageReference Include="RestSharp" Version="108.0.3" /> <PackageReference Include="Selenium.Support" Version="4.8.1" /> <PackageReference Include="Selenium.WebDriver" Version="4.8.1" /> <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="110.0.5481.7700" /> <PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.32.2" /> <PackageReference Include="Selenium.WebDriver.IEDriver" Version="4.8.1" /> <PackageReference Include="Selenium.WebDriver.MicrosoftDriver" Version="17.17134.0" /> <PackageReference Include="Selenium.WebDriver.MSEdgeDriver" Version="110.0.1587.50" /> <PackageReference Include="Selenium.WebDriverBackedSelenium" Version="4.1.0" /> <PackageReference Include="SeleniumExtras.WaitHelpers" Version="1.0.2" /> <PackageReference Include="SpecFlow" Version="3.9.74" /> <PackageReference Include="SpecFlow.Actions.Configuration" Version="0.1.350" /> <PackageReference Include="SpecFlow.Actions.Selenium" Version="0.1.332" /> <PackageReference Include="SpecFlow.Assist.Dynamic" Version="1.4.2" /> <PackageReference Include="SpecFlow.Contrib.Variants" Version="3.9.74" /> <PackageReference Include="SpecFlow.ExternalData" Version="3.9.74" /> <PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" /> <PackageReference Include="SpecFlow.NUnit" Version="3.9.74" /> <PackageReference Include="nunit" Version="3.13.3" /> <PackageReference Include="NUnit3TestAdapter" Version="4.3.1" /> <PackageReference Include="FluentAssertions" Version="6.10.0" /> <PackageReference Include="System.Data.SqlClient" Version="4.8.5" />

Project Format of the SpecFlow project

Sdk-style project format

Test Execution Method

Visual Studio Test Explorer

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

{ "generator": { "addNonParallelizableMarkerForTags": [ "nonparallel" ] }, "bindingCulture": { "name": "en-us" }, "language": { "feature": "en-us" }, "pluginparameters": { "variantkey": "Browser" }, "stepAssemblies": [ { "assembly": "SpecFlow.Contrib.Variants.IntegrationTests.SharedBindings" } ] }

Issue Description

VS2019 - 16.11.23 Not using MS Build Integration, as per document - https://docs.specflow.org/projects/specflow/en/latest/Tools/Generate-Tests-From-MsBuild.html

Similar to this issue - https://github.com/SpecFlowOSS/SpecFlow/issues/561

When a feature file has been amended, and has got a table included in the steps (that is not the example one), and then rebuild the project, visual studio will compare the other feature files that have got table included, and keeps getting the error, because it regenerates the table number each time for the feature.cs files.

Error - [SpecFlow] System.UnauthorizedAccessException: Access to the path is denied.

Works if I take off the read only on the feature.cs files, but really annoying to review for check-ins.

Sorry if this is a bad questions but, is there any easier way to stop this from happening? or rename the tables so that it doesn't get changed all the time?

Steps to Reproduce

Add a step, on a feature file, thats got a table added (that's not the example one)

When I have entered employee details
	| FirstName | LastName | Email | 
	| John | O'Doe | [email protected] |

do this to a few more feature files

then build the project, getting the error

for the affected feature file, I have to check them out and then compare the differences

before build - table1

#line hidden
                TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
                            "FirstName",
                            "LastName",
                            "Email"});
                table1.AddRow(new string[] {
                            "John",
                            "Doe",
                            "[email protected]"});
#line 27

after build - changes to table 38

#line hidden
                TechTalk.SpecFlow.Table table38 = new TechTalk.SpecFlow.Table(new string[] {
                            "FirstName",
                            "LastName",
                            "Email"});
                table38.AddRow(new string[] {
                            "John",
                            "Doe",
                            "[email protected]"});
#line 27

Link to Repro Project

N/A

F1WWFC23 avatar Feb 22 '23 16:02 F1WWFC23