fsprojects / TickSpec

Lean .NET BDD framework with powerful F# integration
Apache License 2.0
134 stars 23 forks source link

Support for dependency injection #1

Closed mchaloupka closed 6 years ago

mchaloupka commented 6 years ago

Usage of dependency injection to create instances will help to resolve more complicated dependencies. Moreover, it enables proper usage of IDisposable classes.

@michalkovy has already a working version using BoDi (DI used in SpecFlow). It would be nice to get it into the official tickspec nuget release. If you will agree, we can create pull request with the feature.

bartelink commented 6 years ago

Hi - feel free to @ me in next time - I'm am marooned on a non-github workflow platform so I'm not maniacally pressing g,n every two minutes like in those happy times.

I believe I may have put this in a discussion on codeplex back in the day myself as it's definitely immensely valuable wrt enabling separating stuff out properly (and Disposable resources are common in acceptance tests IME)

IIRC there's an IServiceProvider in there that just needs to be surfaced?

Key considerations are:

cc @ptrelford any thoughts/considerations you can think of ?

mchaloupka commented 6 years ago

@bartelink I agree with you. I was thinking about adding a dependency to some standard DI. However, it seems to me that it is quite easy to have a very simple DI support without any dependency. See the pull request.

pmbanka commented 6 years ago

@bartelink

Sorry for writing on a closed issue, but I just wanted to ask about this code being released on NuGet. I have a need to pass xUnit's ITestOutputHelper to my TickSpec tests, and IServiceProvider seems to be the only option here, but the latest package on NuGet doesn't have this PR included. Are there any plans to release it soon? :)

bartelink commented 6 years ago

@pmbanka Passing ITestOutputHelper sounds like an ideal use for the facility (but be warned that xUnit does not wire that through to VS2017 atm (which I think is VS' fault)).

Getting a NuGet out is a 'simple' matter of running the script to gen and publish. @ptrelford and I have NuGet publish rights, but I unfortunately have no familiarity with the process and no time right now; if this changes I'll post here when it happens.

Until such a publish happens, the best I can unfortunately offer is the suggestion that a ./build on a fetch of this repo's master will generate a correct DLL with the facility in place as intended.

pmbanka commented 6 years ago

@bartelink thanks for the answer! Yeah I'll use the dll built from the repo :)

Thank you for maintaining this library!