-->

18/02/2020

Power Apps - Test Studio - Automation Testing

At last we got feature of automated testing, improving "Application Life Cycle Management" for Power Apps. (Watch in Full Screen)


In this post we will learn how we will use Test Studio for Power Apps.


I have created a simple power app and there are 3 screens, most of them are self explanatory.

Home Screen: With 2 buttons to navigate to either "New User" Screen or "Search User" screen.
New User Screen: An Edit form with 4 fields and data is saved in a Sharepoint online List.

Search User Screen: Screen with Search Box which retrieves data from Sharepoint Online list. If Serach box is empty , it will display an error message.


Test Studio can be accessed from the "Home" tab, in "Advanced Tools", select "Open Tests" option.


First we need to get familiar with some terminology.

Test Step: An action performed on power app (eg: Clicking a button or Setting a value in text box)

Test Case: Collection of  steps to perform a specific task. (eg: Clicking a button and navigating to desired screen or Entering data required and submitting it to data source by a button click.)

Test Suite: Collection of test cases, i would recommend Create all the test cases pertaining to a Screen under one Test Suite.

Lets start with a Test Suite "Home Screen". I have created 2 Test cases one for each button click.

When you create a new test case, this is what you see initially.


Click the Record button highlighted and start performing the actions on your powerapp and it will record every step you do.

Please note that its better you need to take care of a few things on your own.

#1 Not every test case should begin from Landing page, so you need to write step 1 for navigating to desired page.
#2. All the actions like entering data, clicking buttons and navigating to different page will be registered.
#3. Now you need to write the code for checks in form of Assert() method.

Look at these screen shots and for better understanding.



"Save" and "Publish" the Test Suite. Now select the test Suite and click on "Play" button. This is what you see. (Please watch in full screen)


Now Lets deal with Serach screen. Here are the screenshots of what we registred for test cases.

Empty Search resulting in Error message:

Search with proper data and then see if it fetched any results:

Now here is the Test Suite run for you. (Please watch in full screen)


Lets create test suite for Create New user screen, but this requires use of two screens.

First go to New user screen , enter all the data and then submit, then go to search screen and search for the newly created user.
Record the steps, then modify the values as shown below to make it easy for automation. Now each test will use a different values on the forms.


Now let me show you the Test run for create and then serach for new user. (Watch in Full Screen)



Finally How do you record and trigger some actions if the test cases failed?

Click on the "Test" link shown in below screenshot, and there are two fields to handle post test case and test suite exectuions either to record the runs or to trigger Power Automate flows or to send emails using power app code.



Here is the link for MS documentation for Test Studio. Link.

Let me know if you have any questions or suggestions.



No comments:

Post a Comment