11th salesforce developer group meeting in bilbao

Post on 13-Apr-2017

196 Views

Category:

Engineering

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

Questions?

Sorteo Platform Developer I

Salesforce Certification

¡¡GRACIAS!!Nos vemos en el

próximo SGD

top related