Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appSetting.Json is not getting copied to SpeclowPlusRunner Folder #1668

Closed
8 of 32 tasks
zeeshankhan0330 opened this issue Jul 18, 2019 · 9 comments
Closed
8 of 32 tasks

Comments

@zeeshankhan0330
Copy link

zeeshankhan0330 commented Jul 18, 2019

appSetting.Json is not getting copied to SpeclowPlusRunner Folder

SpecFlow Version:

  • 3.0
  • 2.4
  • 2.3
  • 2.2
  • 2.1
  • 2.0
  • 1.9

Used Test Runner

  • SpecFlow+Runner
  • MSTest
  • NUnit
  • Xunit

Version number: 3.0.352

Project Format of the SpecFlow project

  • Classic project format using packages.config
  • Classic project format using <PackageReference> tags
  • Sdk-style project format

.feature.cs files are generated using

  • SpecFlow.Tools.MsBuild.Generation NuGet package
  • SpecFlowSingleFileGenerator custom tool

Visual Studio Version

  • VS 2019
  • VS 2017
  • VS 2015

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

  • Enabled
  • Disabled

Are the latest Visual Studio updates installed?

  • Yes
  • No, I use Visual Studio version <Major>.<Minor>.<Patch>

.NET Framework:

  • >= .NET 4.5
  • before .NET 4.5
  • .NET Core 2.0
  • .NET Core 2.1
  • .NET Core 2.2
  • .NET Core 3.0

Test Execution Method:

  • Visual Studio Test Explorer
  • TFS/VSTS/Azure DevOps – Task – PLEASE SPECIFY THE NAME OF THE TASK
  • Command line – PLEASE SPECIFY THE FULL COMMAND LINE

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


Repro Project

Issue Description

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.

Steps to Reproduce

@zeeshankhan0330
Copy link
Author

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

@SabotageAndi
Copy link
Contributor

Why do you need the appsettings.json file in the SpecFlowPlusRunner folder? Should it not be in the folder of the test assembly?

@zeeshankhan0330
Copy link
Author

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

@SabotageAndi
Copy link
Contributor

Could you create a small project where we can reproduce the issue? This would help us to analyse this issue.

@tparikka
Copy link

@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.

@SabotageAndi
Copy link
Contributor

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?

@zeeshankhan0330
Copy link
Author

zeeshankhan0330 commented Feb 21, 2020 via email

@SabotageAndi
Copy link
Contributor

Because of inactivity and I think I have answered it, I am closing this issue.
Please open a new issue if necessary.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants