suzi167
suzi167

Reputation: 499

SpecFlow and Testing with the Debugger

We just decided to use SpecFlow in for our unit testing and I created the first scenario.

The tests are running fine,except for one of them and it calls a function in my code.

So obviously that test caught a bug in that function.

I put a breakpoint on the first line of the function which the tests calls and Right Clicked on the Specs project and selected Run With Debugger.

The breakpoint in my function though never gets hit, only the breakpoints in the tests.

So my question is "How do you make SpecFlow run with the Debugger so that I can truly debug my code"

Any suggestions are welcome

Thanks

Upvotes: 3

Views: 7957

Answers (4)

Xen0byte
Xen0byte

Reputation: 109

This solution is for Visual Studio (version 2019 at the time of writing this answer):

  1. Debug > Options > General
  2. Disable "Enable Just My Code".

Upvotes: 2

alansiqueira27
alansiqueira27

Reputation: 8534

https://github.com/techtalk/SpecFlow/wiki/Debugging-Tests

<generator allowDebugGeneratedFiles="true">

Upvotes: 0

Eduardo Brites
Eduardo Brites

Reputation: 4786

If you're using Resharper to run your tests you have to change the VS option: Tools -> Options -> Specflow -> Test Runner from Auto to ReSharper

Upvotes: 1

Ben Smith
Ben Smith

Reputation: 20240

I too have encountered this behaviour. What worked for me is placing a breakpoint in the scenario and also a breakpoint in the step definition file. When you then choose "Run with debugger" you will find that program execution will stop at both breakpoints.

Upvotes: 1

Related Questions