appSetting.Json is not getting copied to SpeclowPlusRunner Folder
Version number: 3.0.352
packages.config<PackageReference> tagsSpecFlow.Tools.MsBuild.Generation NuGet packageSpecFlowSingleFileGenerator custom toolEnable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings<Major>.<Minor>.<Patch>
WHile I Build the project, appsetting.json file is not getting copied into SpecflowPlusRunner folder. Hence test wont get run which are dependent on this json file.
I cant make it work with Pre and Post build because I am running my Test Cases in a Docker Container inside a Linux machine.
SInce Linux has different slash culture than windows for defining path, I am not able to find a solution which works for both Environment.
FOr now I have written a COpy command inside Docker file to copy json file from Bin to SPecFLow folder
Why do you need the appsettings.json file in the SpecFlowPlusRunner folder? Should it not be in the folder of the test assembly?
While running the tests through SpecRun, code which requires appsetting.json wont be executed as it try to find the json file in SpecFlowPlusRunner folder and it wont be available there if not placed explicitly.
When it doesnt find the json file inside SpecRunner folder it gives an error which says cannot find appsetting.json
Could you create a small project where we can reproduce the issue? This would help us to analyse this issue.
@SabotageAndi I have encountered this issue as well. I've set up a small sample repo at https://github.com/tparikka/SpecFlowRunnerPlusAppSettingsIssue that you can download and run that shows the problem. The issue is that content like app settings files need to exist in the same directory as the binary executes from. Items like appsettings are copied to %projectroot%\bin\Debug\netcoreapp3.1 but NOT to %projectroot%\bin\Debug\netcoreapp3.1\SpecFlowPlusRunner\netcoreapp3.1.
I had a look at this issue in the last days.
The issue exists, if you are using the Process test thread isolation. In SharedAppDomain this works.
The reason is that for the process isolation, we have a separate binary that is in its own folder. We have to set the working directory to this folder, because of .NET Core assembly loading.
So you can't simply say "appsettings.json" in accessing the file. We provide an API to get the folder where the test assembly is. It's in the TestRunContext (https://specflow.org/plus/documentation/TestRunContext/) class.
I adjusted our ASP.NET Core example (https://github.com/SpecFlowOSS/SpecFlow-Examples/tree/master/ASP.NET-MVC/BookShop) as an example of how you can use it.
There we use the ConfigurationBuilder. It is here: https://github.com/SpecFlowOSS/SpecFlow-Examples/blob/master/ASP.NET-MVC/BookShop/BookShop.AcceptanceTests/Hooks/Hooks.cs#L26
@tparikka & @zeeshankhan0330 it this information unblocking you?
Thanks !!
On Fri, Feb 21, 2020, 8:24 PM Andreas Willich notifications@github.com
wrote:
I had a look at this issue in the last days.
The issue exists, if you are using the Process test thread isolation. In
SharedAppDomain this works.
The reason is that for the process isolation, we have a separate binary
that is in its own folder. We have to set the working directory to this
folder, because of .NET Core assembly loading.So you can't simply say "appsettings.json" in accessing the file. We
provide an API to get the folder where the test assembly is. It's in the
TestRunContext (https://specflow.org/plus/documentation/TestRunContext/)
class.I adjusted our ASP.NET Core example (
https://github.com/SpecFlowOSS/SpecFlow-Examples/tree/master/ASP.NET-MVC/BookShop)
as an example of how you can use it.
There we use the ConfigurationBuilder. It is here:
https://github.com/SpecFlowOSS/SpecFlow-Examples/blob/master/ASP.NET-MVC/BookShop/BookShop.AcceptanceTests/Hooks/Hooks.cs#L26@tparikka https://github.com/tparikka & @zeeshankhan0330
https://github.com/zeeshankhan0330 it this information unblocking you?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/SpecFlowOSS/SpecFlow/issues/1668?email_source=notifications&email_token=AEOYUKKLBXZWFG5HOIAS4P3RD7TLTA5CNFSM4IE2AYP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMS6URA#issuecomment-589687364,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AEOYUKITEV6PKBTQOK2MZELRD7TLTANCNFSM4IE2AYPQ
.
Because of inactivity and I think I have answered it, I am closing this issue.
Please open a new issue if necessary.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@SabotageAndi I have encountered this issue as well. I've set up a small sample repo at https://github.com/tparikka/SpecFlowRunnerPlusAppSettingsIssue that you can download and run that shows the problem. The issue is that content like app settings files need to exist in the same directory as the binary executes from. Items like appsettings are copied to
%projectroot%\bin\Debug\netcoreapp3.1but NOT to%projectroot%\bin\Debug\netcoreapp3.1\SpecFlowPlusRunner\netcoreapp3.1.