Skip to content

[Feature]: BDD and Test Engine Example #531

Open
@Grant-Archibald-MS

Description

@Grant-Archibald-MS

Is your feature request related to a problem? Please describe.

Would like to create BDD style test using Power App Test Engine

Describe the solution you'd like

Create a Gherkin test using Specflow/Reqnroll.

For example as Specflow test something similar to

Feature: Login
  Scenario: Successful login
    Given the user profile "user1" navigates power app named "MyTest"
    Then the user should be redirected to the dashboard

Exend Test Engine as a NuGet package and extend the ability

using TechTalk.SpecFlow;
using Microsoft.PowerApps.TestEngine;

namespace SpecflowPowerAppsExample
{
    [Binding]
    public class LoginSteps
    {
        private readonly TestEngine _testEngine;

        public LoginSteps()
        {
            _testEngine = new TestEngine();
        }

        [Given(@"the user profile ""(.*)"" navigates power app named ""(.*)""")]
        public void GivenTheUserProfileNavigatesPowerAppNamed(string userProfile, string appName)
        {
            _testEngine.TestSettings.Profile = userProfile1;
            _testEngine.TestSettings.AppName = appName;
        }

        [Then(@"the user should be redirected to the dashboard")]
        public void ThenTheUserShouldBeRedirectedToTheDashboard()
        {
            var powerFxSteps = new List<string>
            {
                "Set(CurrentPage, 'Dashboard')",
                "Validate(CurrentPage == 'Dashboard')"
            };

            foreach (var step in powerFxSteps)
            {
                var result = _testEngine.ExecuteAndReturn(step);
                Assert.IsTrue(result.Contains("true"), $"Step '{step}' failed.");
            }
        }
    }
}

Describe alternatives you've considered

No response

Additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions