View
196
Download
0
Category
Preview:
Citation preview
Salesforce Developer Group
Bilbao, 11 de Marzo, 2016
AgendaBienvenidos!! Presentaciones - ¿tenemos nuevos miembros?Unit tests – ApexMocks – David van AlphenDescanso¿Qué os interesa en el próximo SDG?Comunidad
Bienvenidos!!!¿Qué es SDG? (aka DUG)
¿Nuevos miembros?
ApexMocksby
David van Alphen
Dev/Test TheoryOO Principles – SOLID
Dependency Injection
Enterprise Patterns
Separation of Concerns
Mocking / StubbingMockito, NSubstitute, etc
SOLID Wikipedia - SOLID
SRP – Single Responsibility Principle A class should have one responsibility
O – Open/Closed Principle Open for extension, closed for modification
L – Liskov Substitution Principle Objects should be replaceable by subtypes without affecting correctness of
application
I – Interface Separation Principle Many specific interfaces are better than one general interface
D – Dependency Injection Principle Depend on abstract, not concrete classes
Dependency InjectionWikipedia - Dependency Injection
No Static methods (workaround available)
Constructors
Setters
Salesforce & TestingApex tests
System or integration testsUnit tests
Apexmocks framework
Mix and Match
Mockito vs ApexmocksApex vs Java
No Generics, explicit typing
Concrete classes
Compile on platform
Apexmocks Generatorinterfacemocks.properties
IMyClass=MyClass:MyParentClassOrInterface
Mocks.cls
.gitignore (or equivalent)
Code example 1
Code example 2
Test StructureGiven
Arrange things needed for the test
WhenTrigger the behavior we want to test
ThenConfirm the results are what we expected
Code example 3
Things to AvoidAlways focus on testing public / interface behaviour
Use the framework wisely - don’t verify more behaviour than you need to
Don’t mock too deeply - if you find your unit test having to set up a lot of mocking before you even trigger the behaviour under test, that’s probably a hint that your design could be better
Documentation and HelpExamples found in ApexMocks classes and tests
Code4cloud
GitHub
Andyinthecloud.com - Unit Testing, Apex Enterprise Patterns and ApexMocks Part 1
Andyinthecloud.com - Unit Testing, Apex Enterprise Patterns and ApexMocks Part 2
Feature Enhancements – fork repo on GitHub
Questions?
Video recording
Comunidad de SalesforceCustomer Success Community en Español
Después de uniros haced un comentario en chatter nombrando a @Carolina Ruiz Medina (FinancialForce.com) y preguntad por MVP hours
Spanish Developers Success CommunitySpanish User GroupStackExchange – Preguntas y respuestasDeveloper Forums y otrosSlides Share
Sorteo Platform Developer I
Salesforce Certification
¡¡GRACIAS!!Nos vemos en el
próximo SGD
Recommended