LeanFT integration with SpecFlow

We can integrate the LeanFT tests with SpecFlow very easily. Please follow below steps.

  1. Install SpecFlow extension for Visual Studio.
  2. Add SpecFlow and SpecFlow Runner nuget packages in LeanFT project references.
  3. Add feature files and step definitions.
  4. Execute the scenarios.

Here is the sample feature file. In this feature file, there is a one scenario. We are checking that title of the notepad contains notepad word.

Feature: Notepad feature
Scenario: Verify Notepad title
	Given NotePad is open
	Then I verify that title contains "Notepad" word


Then here is the step definition file for above feature file. Note that we have added LeanFT code in the steps.

using HP.LFT.Report;
using HP.LFT.SDK;
using HP.LFT.SDK.StdWin;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
using TechTalk.SpecFlow;

namespace LeanFtTestProject1
    public class NotepadFeatureSteps
        IWindow notepadWindow;
        [Given(@"NotePad is open")]
        public void GivenNotePadIsOpen()
            SDK.Init(new SdkConfiguration
                ServerAddress = new Uri("ws://localhost:5095")
            ReportConfiguration r = new ReportConfiguration();
            r.IsOverrideExisting = true;
            r.Title = "My LeanFT Report";


            Process appProcess = new Process
                StartInfo = { FileName = @"C:\Windows\System32\notepad.exe" }

            notepadWindow = Desktop.Describe<IWindow>(new WindowDescription
                WindowClassRegExp = "Notepad",
                Index = 0
        [Then(@"I verify that title contains ""(.*)"" word")]
        public void ThenIVerifyThatTitleContainsWord(string p0)
            String title = notepadWindow.WindowTitleRegExp;

You may also like...