Jordi Montana Getting started with Unit Testing for Dynamics 365 Power Apps Development Powerthon 365 Saturday

Getting started with Unit Testing for Dynamics 365 Power Apps Development

Jordi Montana is a pioneer for test driven development for Dynamics 365 and is the author or the FakeXrmEasy Unit testing framework. In this session he shows you how to leverage Mocks implemented to help you replicate the behaviour of your code, Data Driven test decouples the events from the mocks allowing to simplify the unit testing, and executes in the memory to speed up development and tests!

FakeXRMEasy mocks the IOrganisationService to the in Memory Database allowing you to perform CRUD, Query Engine and OrgSVCMessages. We begin by creating a unit test for a plugin that triggers on creation of a phone call from scratch in visual studio. We begin with the Plugin Class Library and install nuget packages for the Dynamics 365 SDK as well as installing a Unit Test Project. By creating a shared project the EarlyBound DLLs will allow you to overcome of the assembly limitations. Now your ready to install FakeXrmEasy with nuget, Visual Studio will open up a get started page to help you find your way with writing your tests!

Add a new Class for the Phonecall Plugin that implements the IPlugin Interface and a single Execute Method. Now you can go to the unit test project and add a new test thats checks to create a phone call history record, that fails if more than one phone call history record exists for a phone call. Now that you have written your test you can now develop your plugin methods with target entity and execute methods.

Also overcoming Mocking Tests with many entity references, and checking number of update operations performed during the test is covered in this session!

https://github.com/jordimontana82/fake-xrm-easy

Leave a Comment

Your email address will not be published.