Skip to content

[Feature]: BDD and Test Engine Example #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Grant-Archibald-MS opened this issue Jan 28, 2025 · 0 comments
Open

[Feature]: BDD and Test Engine Example #531

Grant-Archibald-MS opened this issue Jan 28, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@Grant-Archibald-MS
Copy link
Contributor

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

@Grant-Archibald-MS Grant-Archibald-MS added the enhancement New feature or request label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant