C
C#2y ago
Hark Dand

✅ Set up SpecFlow Logging with 2 different projects

Currently I am trying to do some logging while using the SpecFlow BDD framework. In my solutions I have 2 projects setup (generic names): Project and Project.Specs. Project.Specs is home to the SpecFlow part of my solution. I have my Dependencies setup so that Project.Specs has a reference to Project. All fine and dandy, but I'm struggling to get a Logging tool going. SpecFlow has some documentation on how to use its Output API (https://docs.specflow.org/projects/specflow/en/latest/outputapi/outputapi.html) when only using a single project - at least that's what I'm getting from the documentation. Example: Say I've got a class called Personin Project and a Feature for it in my Project.Specs. I want to have some logging done in a method inside of Person. However, I do not know how this setup would look like in a 2-project-solution. I have also tried using NLog but to no avail. It did not cause any errors but it didn't work either. Thank you very much!
7 Replies
phaseshift
phaseshift2y ago
What the difference one project or two? Why does that matter?
Hark Dand
Hark DandOP2y ago
AFAIK, that's the way recommended by SpecFlow (once again taken from their documentation). All the testing code is supposed to be inside the Project.Specs projects while the actual code resides in Project.
phaseshift
phaseshift2y ago
Well, the examples in the link is clearly showing usage of 'output helper' inside the code impl, not just the test code
Hark Dand
Hark DandOP2y ago
Exactly, that's my problem. I want to have it in the implementation, but since I already have a reference from Project.Specs -> Project, I can't add another reference Project -> Project.Specs since that would be circular. As such I can't use the output helper
phaseshift
phaseshift2y ago
the output helper is from the nuget, so just add another reference to the specflow package
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Hark Dand
Hark DandOP2y ago
The following did the trick: 1. Add the SpecFlow NuGet package with the same version I had in Project.Specs to Project. 2. From there, put a reference into the class which needs to use the logger 3. Assign the logger in test methods Need to find out how to automatically set the logger via the SpecFlow hooks in Project.Specs, but that's a question for another day. Thank you for your help!
Want results from more Discord servers?
Add your server