This post is an introduction to UI Automation Testing for Dynamics 365 CE. I will cover the basic concepts. The next post will show how to get started and provide a practical example.
What is UI Automation?
As the name suggests, UI Automation is the automated testing that happens at the UI layer. Where as unit and integration tests interact with assemblies and APIs, UI tests interact with the actual application UI.
What is involved?
Typically the automated test will open the application UI which in our case is the Dynamics 365 CE web interface and then execute a series of scenarios as if it was the actual user performing the actions.
How does it work?
UI Automation tests typically use frameworks that have the ability to create an instance of a browser. Frameworks also provide APIs or drivers/adaptors that provide you with the ability to interact with the browser instance to perform actions such as navigating to page, filling out forms and clicking on UI elements. Selenium is one of the most widely used frameworks for testing web applications. You can find out more on the Selenium home page.
What framework should you use for Dynamics 365 CE?
There are many UI automation frameworks out there. If you already have a framework being used in your organisation for other web applications there is a good chance it might work well with Dynamics too. For this series I will be using EasyRepro. This is an open source Framework based on Selenium that was released by Microsoft early in 2017 and has recently been updated to support V9. Take look at the GitHub project for more information on the Framework.
What else you need to know about EasyRepro?
- Tests are created using .NET, something most CRM developers are already familiar with which can help with adoption and ensure testing practices as part of your development life cycle.
- It provides you with XrmBrowser object which is a POM (Page Object Model) abstraction on top of the CRM Page. So it gives you API for some of the mostly used actions by the user such as logging in to CRM, interacting with forms and navigation.
- Future updates may include the ability generate code by recording actions or using IDE.
- The framework is easy to use and samples on the GitHub project give you a quick start.
What tests you should be automating?
Before you get going with writing tests I would strongly recommend that you think carefully about what tests it makes sense to automate at UI layer. For this the test pyramid always comes handy.
UI Tests provide very good coverage as they cover the UI and all the layers below such as integrations and any plug-ins you may have. However note the below:
- UI tests take long to run
- UI tests normally run less frequently and are further up in your DevOps pipeline.
- UI tests take longer to develop and maintain
You should have a good number of units tests and integration tests which should provide good coverage for your components and integrations. You can use UI tests to cover UI level features that are not possible to test using Unit and Integration Tests. UI tests can also be used to perform high level smoke testing of your functionality or regression packs. Try to write UI tests once the functionality gets more stable to avoid changes these frequently.
In the next post I will show you how to get started and provide you with a practical examples.