Comments (6)
I found the issue (I have checked out the repo)
If the dependency isn't found, you will get this nasty exception.
So:
namespace SolidToken.SpecFlow.DependencyInjection.Tests
{
public static class TestDependencies
{
[ScenarioDependencies]
public static IServiceCollection CreateServices()
{
var services = new ServiceCollection();
//// Add test dependencies
//services.AddTransient<ITestService, TestService>();
//// ContextInjectionScope (by using AddScoped instead of AddTransient, the context will be scoped to the Feature across bindings)
//services.AddScoped<TestContext>();
//// NOTE: This line is essential so that Microsoft.Extensions.DependencyInjection knows
//// about the SpecFlow bindings (something normally BoDi does automatically).
//// TODO: Find out if we can make this part of the Plugin
//foreach (var type in typeof(TestDependencies).Assembly.GetTypes().Where(t => Attribute.IsDefined(t, typeof(BindingAttribute))))
//{
// services.AddSingleton(type);
//}
return services;
}
}
}
Will demo the issue
from specflow.dependencyinjection.
Let me investigate and I will get back to you.
from specflow.dependencyinjection.
FYI:
<TargetFramework>netcoreapp2.1</TargetFramework>
tried also static
class, but that won't help either.
The big difference is here (I think), that we're using MSTest and not xUnit
from specflow.dependencyinjection.
Is it possible that you have not registered any bindings (yet)?
For example, if you look at DependencyInjectionPluginSteps.cs you will notice the [Binding]
tag that will bind the code to the SpecFlow Feature file.
Currently the plugin requires you to register all the bindings/step definitions (otherwise the DI framework can't find them). So your initialisation code should look like:
var services = new ServiceCollection();
foreach (var type in typeof(TestDependencies).Assembly.GetTypes().Where(t => Attribute.IsDefined(t, typeof(BindingAttribute))))
{
services.AddSingleton(type);
}
return services;
Although this is in the README.md
, I don't think it is very intuitive and I want to solve it as part of issue #7 but haven't landed on a solution yet.
from specflow.dependencyinjection.
ow yes indeed. I missed that! That's the fix.
Would be great if we could make that optional.
from specflow.dependencyinjection.
This could be closed.
from specflow.dependencyinjection.
Related Issues (20)
- Scoped container dispose issue HOT 8
- Add a README to your NuGet Package
- Support IAsyncDisposable HOT 3
- Fix multiple matches in Coverage Report
- Add Package Validation HOT 1
- Request: Support for Microsoft.Extensions.DependencyInjection <= Version 3.1.18 HOT 3
- After ScenarioContext class is used in steps, disposal fails. HOT 2
- Support .NET 6 HOT 1
- Unable to resolve IUnitTestRuntimeProvider
- ITestOutputHelper unavailable when using SpecFlow.xUnit HOT 16
- Tests ran in parallel clash with each other HOT 4
- How to use TestRunContext for inject configuration HOT 1
- Improve README basic example HOT 1
- Change CD to make pre-releases available
- Migration path for AdCodicem's plugin HOT 1
- The given key 'Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope' was not present in the dictionary. HOT 8
- [ScenarioDependencies] replaces DI implementation of the framework or the library(s) HOT 2
- The type 'ServiceCollection' exists in both 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Microsoft.Extensions.DependencyInjection, Version=3.1.0.0 HOT 3
- RegisterProxyBindings does not register step context HOT 1
- Evaluate [FeatureDependencies] HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from specflow.dependencyinjection.