Open tedvanderveen opened 6 years ago
Do you get the error when you use it from NuGet? https://www.nuget.org/packages/SpecFlow.xUnitAdapter/
@gasparnagy I have the same problem, If I use Bindings from a Nuget packages, it doesn't scan external dlls and then it gives same error.
I have the same problem and it appears to be a long running, persistent issue for many. External assemblies containing step definitions are simply not found. This means that context highlighting in Visual Studio does not work.
Not sure if the repo is still in active development or maybe being merged into the main SpecFlow repos?
I found the solution, I had the same problem with .Net Core project, so I will explain it for .Net Core but you can modify it based on your need, of course.
1: You need to upgrade SpecFlow assemblies to newest version, I forked SpecFlow repository and made few changes to make it build for .Net Standard 2.0. Here is my branch; https://github.com/mtrcn/SpecFlow/tree/netstandard
2: Second, you need to create JSON config file in your SpecFlow project root, like following;
specflow.json
{
"specFlow": {
"stepAssemblies": [ { "assembly": "Mete.BDD.Bindings" } ]
}
}
3: Modify following lines;
with these;
var containerBuilder = new ContainerBuilder();
var objectContainer = containerBuilder.CreateGlobalContainer();
var configurationLoader = objectContainer.Resolve<IConfigurationLoader>();
var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(Path.GetFullPath(TestCase.FeatureFile.SpecFlowProject.AssemblyPath));
var testRunnerManager = new TestRunnerManager(
objectContainer,
containerBuilder,
configurationLoader.Load(ConfigurationLoader.GetDefault()),
objectContainer.Resolve<IRuntimeBindingRegistryBuilder>()
);
testRunnerManager.Initialize(assembly);
testRunner = testRunnerManager.GetTestRunner(Thread.CurrentThread.ManagedThreadId);
This will help you load external bindings that are specified in json config.
Hope it helps!
Any chance you can submit a PR (assuming you can make this work for good old VS2015)?
When I clone this repository and run the sample test, it works great!
But when I copied the source of the sample project to an existing solution and adjusted bits like assembly and namespaces used to fit in the overall existing solution, I get the test exception result below. But the suggested part of code in the bottom of the details below, is actually available. Any suggestions on how to fix this?