The new Tests feature in Power Apps

Recently the option to add tests to your Power Apps has been added. This this post I will have a look at this new experimental feature.

Tests (experimental)

The new tests Feature can be found in the Advanced Tools option when you edit your Power Apps.

When you look at the tests the first thing you will find is a message that tells you to enable error management in your app.

Enable Error Management in your app

The Error Management feature is another new and experimental feature that you can enable. You can do this in the app settings.

Once you enabled the above feature you the Test Studio will be opened without the above mentioned dialogue.

Test Studio (Preview)

Test Studio is the place where you can create your tests.

I’m going to create a test by clicking o the record option. This is the easiest way to get started with building tests. There are other ways, but remember Power Apps is aimed at CITIZEN DEVELOPERS! I’m not a citizen developer therefore I will have a look at the pro developer options as well. But for now the record will do.

I select a few values in my drop downs and then click on the Done button. While I’m recording my test the recorder displays all the steps that I’m going through.

My test steps will now appear in the test definition and it looks like my test has been created.

It might be useful to rename the Step descriptions as the recorder will just repeat the steps action expressions.

Time to put this to the test!

Publish and Play the test

Once you are happy with your test you can Save, Publish and play your test. You will have to publish your test before you can play your test

When you play the app your recorded steps will be replayed. (Did you expect anything else?)

But on top of that you can also record your results. Note the OnTestCaseComplete step on the left hand side.

OnTestCaseComplete and OnTestSuiteComplete

The OnTestCaseComplete and OnTestSuiteComplete properties let you run things when the test case is complete.

You can use the TestCaseResult record and TestSuiteResult to collect the results of your test.

The expressions now are similar to the the expression that you would use in Power Apps.  For example you could run a Patch to the Common Data Service.

A simple example is shown below:

//Save to Common Data Service
, Defaults(AppTestResults)
, {
         TestPass: TestCaseResult.TestCaseName & ":" & Text(Now())
         ,TestSuiteId: TestCaseResult.TestSuiteId
         ,TestSuiteName: TestCaseResult.TestSuiteName
         ,TestCaseId: TestCaseResult.TestCaseId
         ,TestCaseName: TestCaseResult.TestCaseName
         ,StartTime: TestCaseResult.StartTime
         ,EndTime: TestCaseResult.EndTime
         ,TestSuccess: TestCaseResult.Success
         ,TestTraces: JSON(TestCaseResult.Traces)
         ,TestFailureMessage: TestCaseResult.TestFailureMessage

Manually editing your test

There are currently 4 test function that you can use. In the earlier screenshot you will have noticed the SetProperty function.

The 4 functions available in a test are:

The Select action matches a user selecting a control.

The SetProperty function is used to interact with a control just the same way as a user would do. So for example enter some text in a text field.

The Assert function lets you test for a specific value. This is used to check the expected value with the actual value that you get. If the expected and actual values don’t match then the test will fail.

The Trace function can be used to add extra information to the results form your OnTestCaseComplete.

If you try any other Power Apps function in your test cases then you will get a cannot be used in a test case warning.

For more learning about Power Apps testing

More details can be found on the following post:

Processing Test Results

Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using

Recent Posts

8 top reasons to use Dataverse or SharePoint lists in the Power Platform

Why would you use Dataverse, if SharePoint lists gives you the option to avoid premium…

6 days ago

Filter by calculated fields in SharePoint using Power Automate

When you read items from a SharePoint list and you want to filter by calculated…

1 week ago

Expected String but got Null, when calling a flow from a Model Driven app

A few weeks ago I looked at calling flows from model driven apps. And for…

1 week ago

Get all your broken connections using Power Automate

To get all your broken connections in the Power Platform can be a challenge. In…

2 weeks ago

Customer Voice a.k.a. Forms Pro the database behind the magic

If you call Customer Voice still Forms Pro or not, have you ever looked into…

2 weeks ago

Many running flows in Power Automate

Recently I noticed that some of my flows end up with many running flows. Types…

3 weeks ago