using TechTalk.SpecFlow; using NUnit.Framework; [Binding] public class MyStepDefinitions { [Given(@"I have entered (.*) into the calculator")] public void GivenIHaveEnteredIntoTheCalculator(int p0) { // Implement step } [When(@"I press add")] public void WhenIPressAdd() { // Implement step } [Then(@"the result should be (.*) on the screen")] public void ThenTheResultShouldBeOnTheScreen(int p0) { // Implement step } } [TestFixture] public class MyFeature { [Test] public void RunSpecFlowTest() { var testRunner = TestRunnerManager.GetTestRunner(); var testResult = testRunner.RunScenario(typeof(MyStepDefinitions), "My Scenario"); Assert.IsTrue(testResult.ScenarioExecutionStatus == ScenarioExecutionStatus.OK); } }
using TechTalk.SpecFlow; using Microsoft.VisualStudio.TestTools.UnitTesting; [Binding] public class MyStepDefinitions { [Given(@"I have entered (.*) into the calculator")] public void GivenIHaveEnteredIntoTheCalculator(int p0) { // Implement step } [When(@"I press add")] public void WhenIPressAdd() { // Implement step } [Then(@"the result should be (.*) on the screen")] public void ThenTheResultShouldBeOnTheScreen(int p0) { // Implement step } } [TestClass] public class MyFeature { [TestMethod] public void RunSpecFlowTest() { var testRunner = TestRunnerManager.GetTestRunner(); var testResult = testRunner.RunScenario(typeof(MyStepDefinitions), "My Scenario"); Assert.IsTrue(testResult.ScenarioExecutionStatus == ScenarioExecutionStatus.OK); } }Package Library: TechTalk.SpecFlow package library is used to integrate SpecFlow with .NET applications and includes all the necessary classes for creating and running SpecFlow tests.