Giter VIP home page Giter VIP logo

Comments (6)

gasparnagy avatar gasparnagy commented on June 12, 2024

Do you get the error when you use it from NuGet? https://www.nuget.org/packages/SpecFlow.xUnitAdapter/

from specflow.xunitadapter.

mtrcn avatar mtrcn commented on June 12, 2024

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

from specflow.xunitadapter.

HoraceBury avatar HoraceBury commented on June 12, 2024

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.

from specflow.xunitadapter.

tedvanderveen avatar tedvanderveen commented on June 12, 2024

Not sure if the repo is still in active development or maybe being merged into the main SpecFlow repos?

from specflow.xunitadapter.

mtrcn avatar mtrcn commented on June 12, 2024

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;

var assembly = Assembly.Load(new AssemblyName(TestCase.FeatureFile.SpecFlowProject.Name));
testRunner = TestRunnerManager.GetTestRunner(assembly);

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!

from specflow.xunitadapter.

HoraceBury avatar HoraceBury commented on June 12, 2024

Any chance you can submit a PR (assuming you can make this work for good old VS2015)?

from specflow.xunitadapter.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.