0
votes

I have a SpecFlow test, which feature file and step definitions are in different projects. It passes when running inside Visual Studio, but fails when running from the command line using MsTest.

The output error message is: No matching step definition found for the step. Use the following code to create one:

 [Given(@"I am a member")]
 public void GivenIAMAMember()
 {
      ScenarioContext.Current.Pending();
 }

Test method threw exception: System.IO.FileNotFoundException: Could not load file or assembly 'nunit.framework' or one of its dependencies. The system cannot find the file specified.WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Anyone could give me any ideas?

Thank you in advance!

1
it might also be useful to know how you are running the tests with MSTest. Are you compiling again? Or in a different environment, or is this using the files as built by VisualStudio?Sam Holder
I am running the tests with MsTest in the same folder where both assemblies reside (the bin folder). The testcontainer file is using the dll built by VisualStudio.TestEver

1 Answers

0
votes

Your steps dll is likely not being loaded into memory by MSTest as nothing is referencing it. In VS specflow ensures that it is loaded I believe.

You can force it to be loaded, which might help by doing something like this:

  • create a class in your steps dll.
  • in your project with the feature files create a partial class with the same name as the test class specflow generated
  • in this partial class add a field and set it to a new instance of the class from the steps dll.

This should force the steps dll to be loaded into the test process and so then the steps should be discoverable.

Please note I have not tested this and its just off the top of my head.

Good luck.