Debugging scenarios - adamralph/xbehave.net GitHub Wiki

There's nothing special about an xBehave.net scenario with respect to debugging. You can use all your usual debugging tools, such as break points, stepping, etc.

However, it's important to remember that the execution of a scenario method only defines the steps in the scenario. The steps themselves are executed after the scenario method has exited.

The incorrect way to debug

A common mistake is to put a break point on an entire step statement like so:

image

When you hit this break point, the values of x and y will be 0 because none of the steps have been executed yet, including the step you are attempting to debug:

image

The correct way to debug

Put your break point on a statement in the body of a step like so:

image

When you hit this break point, the values of x and y will be 1 and 2 because the previous steps have been executed, and the step you are attempting to debug is being executed:

image

Source stepping

xBehave.net (version 2.2.0 onwards) supports source stepping via SourceLink. To set this up in Visual Studio, follow the instructions.