SlideShare une entreprise Scribd logo
1  sur  14
Télécharger pour lire hors ligne
Apex Test Classes
@testsetup
Paris Salesforce Developer Group
03/06/2015
Fabien Taillon
@FabienTaillon
In every Test Class you should :
 Create your own test data
 Test your code
 Assert the results of your test
What is a Test Class
Test Class
Usual Test Class
Method 1
Create Data
Execute Test 1
Assert Results 1
Method 2
Create Data
Execute Test 2
Assert Results 2
Method 3
Create Data
Execute Test 3
Assert Results 3
Test Class
Usual Test Class
Method 1
Create Data
Execute Test 1
Assert Results 1
Method 2
Create Data
Execute Test 2
Assert Results 2
Method 3
Create Data
Execute Test 3
Assert Results 3
Execute Test 1
Assert Results 1
Execute Test 2
Assert Results 2
Execute Test 3
Assert Results 3
This is the aim and heart of your tests
Test Class
Usual Test Class
Method 1
Create Data
Execute Test 1
Assert Results 1
Method 2
Create Data
Execute Test 2
Assert Results 2
Method 3
Create Data
Execute Test 3
Assert Results 3
Create Data Create Data Create Data
This must be done, but potentially doing X times the same thing !!
Test Class
Usual Test Class
Method 1
Create Data
Execute Test 1
Assert Results 1
Method 2
Create Data
Execute Test 2
Assert Results 2
Method 3
Create Data
Execute Test 3
Assert Results 3
ex: 30s ex: 30s ex: 30s
This must be done, but potentially doing X times the same thing !!
Meaning execution time lost for nothing !!
ex: 1mn30 instead of 30s
Create Data Create Data Create Data
What if we could do the same job
only once ?
What if we could do the same job
only once ?
Here comes @testsetup !
Test Class
Usual Test Class
Method 1
Create Data
Execute Test 1
Assert Results 1
Method 2
Create Data
Execute Test 2
Assert Results 2
Method 3
Create Data
Execute Test 3
Assert Results 3
Test Class
@testsetup
Method 1
Execute Test 1
Assert Results 1
@testsetup method : Create Data
Method 2
Execute Test 2
Assert Results 2
Method 3
Execute Test 3
Assert Results 3
Test Class
@testsetup
Method 1
Execute Test 1
Assert Results 1
@testsetup method : Create Data
Method 2
Execute Test 2
Assert Results 2
Method 3
Execute Test 3
Assert Results 3
@testsetup method : Create Data
• Creation of test data is now common to all methods
• Executed once
• Rollbacked between all methods
 Test classes execute faster !!
DEMO
 Test setup methods are supported only with the default data
isolation mode for a test class
 Multiple test setup methods are allowed in a test class, but the
order in which they’re executed by the testing framework isn’t
guaranteed
 If a fatal error occurs during the execution of a test setup method,
the entire test class fails, and no further tests in the class are
executed
 If a test setup method calls a non-test method of another class, no
code coverage is calculated for the non-test method
What else ?
Meetup 06/2015 - @testsetup

Contenu connexe

Tendances

Testing All the Way Down, and Other Directions
Testing All the Way Down, and Other DirectionsTesting All the Way Down, and Other Directions
Testing All the Way Down, and Other DirectionsJames Thomas
 
Custom Validation PHP
Custom Validation PHPCustom Validation PHP
Custom Validation PHPProdigyView
 
Physics lab rubric
Physics lab rubricPhysics lab rubric
Physics lab rubricjsawyer3434
 
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...Justin Hunter
 
How To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitHow To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitBugRaptors
 
Duplicate Contact Trigger || Trigger Logic Building || #ApexTrigger #Salesforce
Duplicate Contact Trigger || Trigger Logic Building || #ApexTrigger #SalesforceDuplicate Contact Trigger || Trigger Logic Building || #ApexTrigger #Salesforce
Duplicate Contact Trigger || Trigger Logic Building || #ApexTrigger #SalesforceAmit Singh
 
Icse2014 v3
Icse2014 v3Icse2014 v3
Icse2014 v3SAIL_QU
 
Automated
AutomatedAutomated
Automatedingveb
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practicesnickokiss
 
Resource Leaks in Java
Resource Leaks in JavaResource Leaks in Java
Resource Leaks in JavaCoverity
 
Test Design For Everyone
Test Design For EveryoneTest Design For Everyone
Test Design For EveryoneAlan Page
 
Concurrency Errors in Java
Concurrency Errors in JavaConcurrency Errors in Java
Concurrency Errors in JavaCoverity
 
There is NO test automation
There is NO test automationThere is NO test automation
There is NO test automationEddy Bruin
 
OSS Java Analysis - What You Might Be Missing
OSS Java Analysis - What You Might Be MissingOSS Java Analysis - What You Might Be Missing
OSS Java Analysis - What You Might Be MissingCoverity
 

Tendances (19)

Testing All the Way Down, and Other Directions
Testing All the Way Down, and Other DirectionsTesting All the Way Down, and Other Directions
Testing All the Way Down, and Other Directions
 
Ecet330 lab rubric
Ecet330 lab rubricEcet330 lab rubric
Ecet330 lab rubric
 
Custom Validation PHP
Custom Validation PHPCustom Validation PHP
Custom Validation PHP
 
Physics lab rubric
Physics lab rubricPhysics lab rubric
Physics lab rubric
 
Unit testing
Unit testingUnit testing
Unit testing
 
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
 
How To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitHow To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnit
 
Duplicate Contact Trigger || Trigger Logic Building || #ApexTrigger #Salesforce
Duplicate Contact Trigger || Trigger Logic Building || #ApexTrigger #SalesforceDuplicate Contact Trigger || Trigger Logic Building || #ApexTrigger #Salesforce
Duplicate Contact Trigger || Trigger Logic Building || #ApexTrigger #Salesforce
 
Icse2014 v3
Icse2014 v3Icse2014 v3
Icse2014 v3
 
Automated
AutomatedAutomated
Automated
 
Testing &ampdebugging
Testing &ampdebuggingTesting &ampdebugging
Testing &ampdebugging
 
What is testing
What is testingWhat is testing
What is testing
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
 
Resource Leaks in Java
Resource Leaks in JavaResource Leaks in Java
Resource Leaks in Java
 
Making method calls_simpler
Making method calls_simplerMaking method calls_simpler
Making method calls_simpler
 
Test Design For Everyone
Test Design For EveryoneTest Design For Everyone
Test Design For Everyone
 
Concurrency Errors in Java
Concurrency Errors in JavaConcurrency Errors in Java
Concurrency Errors in Java
 
There is NO test automation
There is NO test automationThere is NO test automation
There is NO test automation
 
OSS Java Analysis - What You Might Be Missing
OSS Java Analysis - What You Might Be MissingOSS Java Analysis - What You Might Be Missing
OSS Java Analysis - What You Might Be Missing
 

En vedette

Responsive Web Design with Visualforce
Responsive Web Design with VisualforceResponsive Web Design with Visualforce
Responsive Web Design with VisualforceKeir Bowden
 
Force.com Friday : Intro to Visualforce
Force.com Friday : Intro to VisualforceForce.com Friday : Intro to Visualforce
Force.com Friday : Intro to VisualforceSalesforce Developers
 
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for MobileVisualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for MobileSalesforce Developers
 
Making External Web Pages Interact With Visualforce
Making External Web Pages Interact With VisualforceMaking External Web Pages Interact With Visualforce
Making External Web Pages Interact With VisualforceSalesforce Developers
 
Salesforce Presentation
Salesforce PresentationSalesforce Presentation
Salesforce PresentationChetna Purohit
 

En vedette (10)

Introducing Visualforce
Introducing VisualforceIntroducing Visualforce
Introducing Visualforce
 
Responsive Web Design with Visualforce
Responsive Web Design with VisualforceResponsive Web Design with Visualforce
Responsive Web Design with Visualforce
 
Force.com Friday : Intro to Visualforce
Force.com Friday : Intro to VisualforceForce.com Friday : Intro to Visualforce
Force.com Friday : Intro to Visualforce
 
Force.com Friday - Intro to Visualforce
Force.com Friday - Intro to VisualforceForce.com Friday - Intro to Visualforce
Force.com Friday - Intro to Visualforce
 
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for MobileVisualforce in Salesforce1: Optimizing your User Interface for Mobile
Visualforce in Salesforce1: Optimizing your User Interface for Mobile
 
Making External Web Pages Interact With Visualforce
Making External Web Pages Interact With VisualforceMaking External Web Pages Interact With Visualforce
Making External Web Pages Interact With Visualforce
 
Introduction to Visualforce
Introduction to VisualforceIntroduction to Visualforce
Introduction to Visualforce
 
Introduction to Visualforce Webinar
Introduction to Visualforce WebinarIntroduction to Visualforce Webinar
Introduction to Visualforce Webinar
 
Introduction to Visualforce
Introduction to VisualforceIntroduction to Visualforce
Introduction to Visualforce
 
Salesforce Presentation
Salesforce PresentationSalesforce Presentation
Salesforce Presentation
 

Similaire à Meetup 06/2015 - @testsetup

Dev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetDev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetdevlabsalliance
 
Testclass [Autosaved]
Testclass [Autosaved]Testclass [Autosaved]
Testclass [Autosaved]Suraj Singh
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven DevelopmentFerdous Mahmud Shaon
 
Unit testing in Force.com platform
Unit testing in Force.com platformUnit testing in Force.com platform
Unit testing in Force.com platformChamil Madusanka
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonCefalo
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introductionDenis Bazhin
 
Test driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesTest driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesNarendra Pathai
 
An Introduction to unit testing
An Introduction to unit testingAn Introduction to unit testing
An Introduction to unit testingSteven Casey
 
TestNG Session presented in PB
TestNG Session presented in PBTestNG Session presented in PB
TestNG Session presented in PBAbhishek Yadav
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration TestingDavid Berliner
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit TestingMike Lively
 
On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...
On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...
On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...Fabio Palomba
 
Dreamforce Campfire - Apex Testing Tips and Tricks
Dreamforce Campfire - Apex Testing Tips and TricksDreamforce Campfire - Apex Testing Tips and Tricks
Dreamforce Campfire - Apex Testing Tips and TricksDaniel Ballinger
 
GCSE ICT TESTING
GCSE ICT TESTING GCSE ICT TESTING
GCSE ICT TESTING morgan98
 

Similaire à Meetup 06/2015 - @testsetup (20)

Dev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetDev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdet
 
Test ng
Test ngTest ng
Test ng
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
Testing with Junit4
Testing with Junit4Testing with Junit4
Testing with Junit4
 
Test ng tutorial
Test ng tutorialTest ng tutorial
Test ng tutorial
 
Testclass [Autosaved]
Testclass [Autosaved]Testclass [Autosaved]
Testclass [Autosaved]
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 
Unit testing in Force.com platform
Unit testing in Force.com platformUnit testing in Force.com platform
Unit testing in Force.com platform
 
TDD Best Practices
TDD Best PracticesTDD Best Practices
TDD Best Practices
 
Getting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud ShaonGetting started with Test Driven Development - Ferdous Mahmud Shaon
Getting started with Test Driven Development - Ferdous Mahmud Shaon
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 
Test driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesTest driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practices
 
An Introduction to unit testing
An Introduction to unit testingAn Introduction to unit testing
An Introduction to unit testing
 
TestNG Session presented in PB
TestNG Session presented in PBTestNG Session presented in PB
TestNG Session presented in PB
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Testing
TestingTesting
Testing
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...
On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...
On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...
 
Dreamforce Campfire - Apex Testing Tips and Tricks
Dreamforce Campfire - Apex Testing Tips and TricksDreamforce Campfire - Apex Testing Tips and Tricks
Dreamforce Campfire - Apex Testing Tips and Tricks
 
GCSE ICT TESTING
GCSE ICT TESTING GCSE ICT TESTING
GCSE ICT TESTING
 

Plus de Paris Salesforce Developer Group

La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !Paris Salesforce Developer Group
 
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?Paris Salesforce Developer Group
 
Mon Expérience avec le Certified Technical Architect Review Board
 Mon Expérience avec le Certified Technical Architect Review Board Mon Expérience avec le Certified Technical Architect Review Board
Mon Expérience avec le Certified Technical Architect Review BoardParis Salesforce Developer Group
 
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...Paris Salesforce Developer Group
 
Pratiques administration avancées et techniques de développement
Pratiques administration avancées et techniques de développementPratiques administration avancées et techniques de développement
Pratiques administration avancées et techniques de développementParis Salesforce Developer Group
 
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15Paris Salesforce Developer Group
 
Versionning et travail en équipe avec Salesforce - 27/11/2014
Versionning et travail en équipe avec Salesforce - 27/11/2014Versionning et travail en équipe avec Salesforce - 27/11/2014
Versionning et travail en équipe avec Salesforce - 27/11/2014Paris Salesforce Developer Group
 
Paris Salesforce Developer Group - 16 09 2014 - Summer '14
Paris Salesforce Developer Group - 16 09 2014 - Summer '14Paris Salesforce Developer Group - 16 09 2014 - Summer '14
Paris Salesforce Developer Group - 16 09 2014 - Summer '14Paris Salesforce Developer Group
 

Plus de Paris Salesforce Developer Group (19)

Pour Noël, devenez chrome extensioniste!
Pour Noël, devenez chrome extensioniste!Pour Noël, devenez chrome extensioniste!
Pour Noël, devenez chrome extensioniste!
 
GraphQL (la nouvelle API de référence de Salesforce ?!)
GraphQL (la nouvelle API de référence de Salesforce ?!)GraphQL (la nouvelle API de référence de Salesforce ?!)
GraphQL (la nouvelle API de référence de Salesforce ?!)
 
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
 
Introduction à la plateforme Anypoint de MuleSoft
Introduction à la plateforme Anypoint de MuleSoftIntroduction à la plateforme Anypoint de MuleSoft
Introduction à la plateforme Anypoint de MuleSoft
 
Release spring '22 - Community Groups français
Release spring '22 - Community Groups françaisRelease spring '22 - Community Groups français
Release spring '22 - Community Groups français
 
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?
 
Mon Expérience avec le Certified Technical Architect Review Board
 Mon Expérience avec le Certified Technical Architect Review Board Mon Expérience avec le Certified Technical Architect Review Board
Mon Expérience avec le Certified Technical Architect Review Board
 
Mieux acheminer les emails avec salesforce
Mieux acheminer les emails avec salesforceMieux acheminer les emails avec salesforce
Mieux acheminer les emails avec salesforce
 
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...
 
Dreamforce Global Gathering
Dreamforce Global GatheringDreamforce Global Gathering
Dreamforce Global Gathering
 
Getting started with Salesforce DX
Getting started with Salesforce DXGetting started with Salesforce DX
Getting started with Salesforce DX
 
Pratiques administration avancées et techniques de développement
Pratiques administration avancées et techniques de développementPratiques administration avancées et techniques de développement
Pratiques administration avancées et techniques de développement
 
Sensibilisation à la Sécurité Salesforce
Sensibilisation à la Sécurité SalesforceSensibilisation à la Sécurité Salesforce
Sensibilisation à la Sécurité Salesforce
 
Salesforce Performance hacks - Client Side
Salesforce Performance hacks - Client SideSalesforce Performance hacks - Client Side
Salesforce Performance hacks - Client Side
 
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15
 
Meetup Custom Metadata - 1st Part
Meetup Custom Metadata - 1st PartMeetup Custom Metadata - 1st Part
Meetup Custom Metadata - 1st Part
 
Lightning week - Paris DUG
Lightning week - Paris DUGLightning week - Paris DUG
Lightning week - Paris DUG
 
Versionning et travail en équipe avec Salesforce - 27/11/2014
Versionning et travail en équipe avec Salesforce - 27/11/2014Versionning et travail en équipe avec Salesforce - 27/11/2014
Versionning et travail en équipe avec Salesforce - 27/11/2014
 
Paris Salesforce Developer Group - 16 09 2014 - Summer '14
Paris Salesforce Developer Group - 16 09 2014 - Summer '14Paris Salesforce Developer Group - 16 09 2014 - Summer '14
Paris Salesforce Developer Group - 16 09 2014 - Summer '14
 

Dernier

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Meetup 06/2015 - @testsetup

  • 1. Apex Test Classes @testsetup Paris Salesforce Developer Group 03/06/2015 Fabien Taillon @FabienTaillon
  • 2. In every Test Class you should :  Create your own test data  Test your code  Assert the results of your test What is a Test Class
  • 3. Test Class Usual Test Class Method 1 Create Data Execute Test 1 Assert Results 1 Method 2 Create Data Execute Test 2 Assert Results 2 Method 3 Create Data Execute Test 3 Assert Results 3
  • 4. Test Class Usual Test Class Method 1 Create Data Execute Test 1 Assert Results 1 Method 2 Create Data Execute Test 2 Assert Results 2 Method 3 Create Data Execute Test 3 Assert Results 3 Execute Test 1 Assert Results 1 Execute Test 2 Assert Results 2 Execute Test 3 Assert Results 3 This is the aim and heart of your tests
  • 5. Test Class Usual Test Class Method 1 Create Data Execute Test 1 Assert Results 1 Method 2 Create Data Execute Test 2 Assert Results 2 Method 3 Create Data Execute Test 3 Assert Results 3 Create Data Create Data Create Data This must be done, but potentially doing X times the same thing !!
  • 6. Test Class Usual Test Class Method 1 Create Data Execute Test 1 Assert Results 1 Method 2 Create Data Execute Test 2 Assert Results 2 Method 3 Create Data Execute Test 3 Assert Results 3 ex: 30s ex: 30s ex: 30s This must be done, but potentially doing X times the same thing !! Meaning execution time lost for nothing !! ex: 1mn30 instead of 30s Create Data Create Data Create Data
  • 7. What if we could do the same job only once ?
  • 8. What if we could do the same job only once ? Here comes @testsetup !
  • 9. Test Class Usual Test Class Method 1 Create Data Execute Test 1 Assert Results 1 Method 2 Create Data Execute Test 2 Assert Results 2 Method 3 Create Data Execute Test 3 Assert Results 3
  • 10. Test Class @testsetup Method 1 Execute Test 1 Assert Results 1 @testsetup method : Create Data Method 2 Execute Test 2 Assert Results 2 Method 3 Execute Test 3 Assert Results 3
  • 11. Test Class @testsetup Method 1 Execute Test 1 Assert Results 1 @testsetup method : Create Data Method 2 Execute Test 2 Assert Results 2 Method 3 Execute Test 3 Assert Results 3 @testsetup method : Create Data • Creation of test data is now common to all methods • Executed once • Rollbacked between all methods  Test classes execute faster !!
  • 12. DEMO
  • 13.  Test setup methods are supported only with the default data isolation mode for a test class  Multiple test setup methods are allowed in a test class, but the order in which they’re executed by the testing framework isn’t guaranteed  If a fatal error occurs during the execution of a test setup method, the entire test class fails, and no further tests in the class are executed  If a test setup method calls a non-test method of another class, no code coverage is calculated for the non-test method What else ?