Automated Testing for Dynamics CRM
Unit Testing
Custom Workflow Activities
Wael Hamze
Ramón Tébar
@CRMUG
Wael Hamze
▪ Solution Architect
▪ @WaelHamze
▪ http://www.linkedin.com/in/waelhamze
@CRMUG
Ramon Tebar
▪ Solution Architect
▪ Microsoft CRM MVP
▪ http://www.ramontebar.com
@CRMUG
Automated Testing Series
1. Unit Testing Plug-ins in Dynamics CRM 2013
2. Unit Testing Custom Workflow Activities in
Dynamics CRM 2013 [Tuesday, July 8]
3. Integration Testing Plug-Ins in Dynamics CRM
2013 [Tuesday, July 29]
4. Integration Testing Custom Workflow
Activities in Dynamics CRM 2013 [Wednesday,
August 27]
@CRMUG
Automated Testing Series
2. Unit Testing Custom Workflow Activities in
Dynamics CRM 2013
▪ This session will focus on using the Unit Testing concepts from the
previous session and show you how you can apply that to test
custom workflow activities using Moq.
▪ Breaking limitations: Shims
▪ This session will also introduce you to the xRM Test Framework
and show you how you can speed up the creation of your tests.
▪ Finally you will see how you can execute these unit tests as part
of your builds.
@CRMUG
CRM Workflow Runtime
CRM Workflow Runtime
Worflow
Worflow
Process
Custom
Workflow
Activity
• Sync. Worflows
• Async. Workflows
• Dialogs
• Actions
@CRMUG
Unit Test Mock<Extensions> Workflow Runtime
Create
Setup Mocks
Create + Inputs
Create + Inject Activity + Extensions
Execute
Workflow Activity
Invoke
Call
Verify
Outputs
@CRMUG
Demo
Our first test
@CRMUG
▪ It is definitely Possible
▪ It is definitely Helpful
▪ Too much effort using standard approach
Unit Testing Comments
@CRMUG
xRM Test Framework
@CRMUG
Demo
Now using
Xrm Test Framework
https://xrmtestframework.codeplex.com
@CRMUG
Demo
Data Driven Test
with an
External Service
Dependency
@CRMUG
Why Write Unit Tests?
▪ Validate all components work on their own
▪ Ability to Test Plug-ins & Custom Workflow
Activities without CRM Environment
▪ Ability to Test without Deployment
▪ Tests run much quicker
▪ Detect bugs very early and fix quickly
▪ Debug locally with Visual Studio
@CRMUG
When to Run your Tests?
▪ Run your Tests locally before you Check-In
▪ Run your Tests as part of your Build
▪ Consider using Gated Check-In Builds
@CRMUG
Demo
Using your tests:
Continuous
Integration

Automated Testing for Dynamics CRM 2 - CRMUG 2014

  • 1.
    Automated Testing forDynamics CRM Unit Testing Custom Workflow Activities Wael Hamze Ramón Tébar
  • 2.
    @CRMUG Wael Hamze ▪ SolutionArchitect ▪ @WaelHamze ▪ http://www.linkedin.com/in/waelhamze
  • 3.
    @CRMUG Ramon Tebar ▪ SolutionArchitect ▪ Microsoft CRM MVP ▪ http://www.ramontebar.com
  • 4.
    @CRMUG Automated Testing Series 1.Unit Testing Plug-ins in Dynamics CRM 2013 2. Unit Testing Custom Workflow Activities in Dynamics CRM 2013 [Tuesday, July 8] 3. Integration Testing Plug-Ins in Dynamics CRM 2013 [Tuesday, July 29] 4. Integration Testing Custom Workflow Activities in Dynamics CRM 2013 [Wednesday, August 27]
  • 5.
    @CRMUG Automated Testing Series 2.Unit Testing Custom Workflow Activities in Dynamics CRM 2013 ▪ This session will focus on using the Unit Testing concepts from the previous session and show you how you can apply that to test custom workflow activities using Moq. ▪ Breaking limitations: Shims ▪ This session will also introduce you to the xRM Test Framework and show you how you can speed up the creation of your tests. ▪ Finally you will see how you can execute these unit tests as part of your builds.
  • 6.
    @CRMUG CRM Workflow Runtime CRMWorkflow Runtime Worflow Worflow Process Custom Workflow Activity • Sync. Worflows • Async. Workflows • Dialogs • Actions
  • 7.
    @CRMUG Unit Test Mock<Extensions>Workflow Runtime Create Setup Mocks Create + Inputs Create + Inject Activity + Extensions Execute Workflow Activity Invoke Call Verify Outputs
  • 8.
  • 9.
    @CRMUG ▪ It isdefinitely Possible ▪ It is definitely Helpful ▪ Too much effort using standard approach Unit Testing Comments
  • 10.
  • 11.
    @CRMUG Demo Now using Xrm TestFramework https://xrmtestframework.codeplex.com
  • 12.
    @CRMUG Demo Data Driven Test withan External Service Dependency
  • 13.
    @CRMUG Why Write UnitTests? ▪ Validate all components work on their own ▪ Ability to Test Plug-ins & Custom Workflow Activities without CRM Environment ▪ Ability to Test without Deployment ▪ Tests run much quicker ▪ Detect bugs very early and fix quickly ▪ Debug locally with Visual Studio
  • 14.
    @CRMUG When to Runyour Tests? ▪ Run your Tests locally before you Check-In ▪ Run your Tests as part of your Build ▪ Consider using Gated Check-In Builds
  • 15.