Skip to content

Quick start

Michael W Powell edited this page Dec 8, 2020 · 4 revisions
  • Ensure you are able to execute xUnit.net tests, in Visual Studio or your environment of choice
  • Create a new class library project and add a reference to xWellBehaved.net
  • Add the following code to a class file in your project:
namespace Xwellbehaved
{
    using Xunit;

    public class DebuggingScenarios
    {
        [Scenario]
        public virtual void Addition(int x, int y, int expected, int actual, Calculator calculator)
        {
            "Let x equal to 1".x(() => x = 1);

            "Let y equal to 2".x(() => y = 2);

            "Let expected equal to 3".x(() => expected = 3);

            "And given calculator".x(() => calculator = new Calculator());

            "When x plus y".x(() => actual = calculator.AssertNotNull().Add(x, y));

            "Then actual equal to expected".x(() => actual.AssertEqual(expected));
        }
    }
}
  • Execute the scenario in exactly the same way you would normally execute an xUnit.net Fact or Theory

Voilà! You just wrote and ran your first xWellBehaved.net scenario. You will see that five successful tests will have run: one for each step in the scenario.

For more information, see Writing scenarios and Running scenarios.

Clone this wiki locally