SlideShare a Scribd company logo
TDD in CQ5/AEM
Sagar Sane
What’s on the plate?
● What is Test driven development (TDD)?
● Why TDD / BDD?
● CQ backend and Spock testing framework
● Live code
Not on the plate
● Advanced testing techniques
○ Features of Spock Framework
● Much about testing your UI / JS
● Software Consultant II / Tech lead
● WEM Consultant
○ Backend development
○ Comfortable with Java (/JSP) and Groovy
● I don’t dislike front-end development :-)
About me
I became a programmer because of the
‘science’ in programming,
but, I remained a programmer because of the
‘art’ in programming.
I believe..
Some people have very strong opinions about this...
No, REALLY!
Test Driven Development
● Write Test First (extreme programming)
○ Technical meaning
○ Design your code around the tests
● Write a lot of tests
○ Milder approach
What is a Unit Test in CQ/AEM?
Benefits of Testing
● Find bugs early
● Make it easy for a new person on your
project
○ Read the tests if you don’t understand the code
● Improve code quality
Benefits of Testing
● Helps during code re-factoring
● A good test is worth a thousand comments
● Executable documentation
BDD
● Behavior Driven Development
● Writing tests from the customer’s /
stakeholder’s point of view
● It really is TDD done well!
● More expressive than TDD
//Variables
expected, v1, v2, ..
//Execute feature
actual = System.executeFeature(v1, v2, ..)
//The system gives output as expected
assert actual == expected
Test Driven Development in AEM/CQ5
CQ/AEM and Spock
● What is Spock Framework? [ link ]
● Why is it awesome? [ link ] [ link ]
○ Is beautiful
● It can be used to test your CQ/AEM
backend!
A basic Spock Feature
//Spock ‘feature’
def "My component should just work"() {
given:
final variables = [ //initial conditions ]
final expected = new MyComponent(...)
when:
final actual = MyComponent.create(variables)
then:
actual == expected
}
Time for some real code...
What ‘new’ will we see?
● Mocks in spock
● setupSpec(), cleanupSpec()
● @Ignore(), @Shared
What all can you do?
● Unit tests for servlets, services
● Integration tests
● Functional tests for your rest APIs
● Even UI tests! (with Geb)
What all can you do?
Test Automation
Where to go from here?
● Don’t have to start big
● Add tests to the code that is important,
needs change
● Start new implementations with TDD
The art of programming!
Thank you!
Ad

More Related Content

What's hot (20)

Test Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and CucumberTest Automation Framework with BDD and Cucumber
Test Automation Framework with BDD and Cucumber
Rhoynar Software Consulting
 
Integration Testing in AEM
Integration Testing in AEMIntegration Testing in AEM
Integration Testing in AEM
connectwebex
 
Polyglot engineering
Polyglot engineeringPolyglot engineering
Polyglot engineering
Klaus Salchner
 
Getting Started With Cypress
Getting Started With CypressGetting Started With Cypress
Getting Started With Cypress
Knoldus Inc.
 
Test Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaTest Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and Mocha
Salesforce Developers
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
toddbr
 
Cucumber BDD
Cucumber BDDCucumber BDD
Cucumber BDD
Pravin Dsilva
 
Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkin
Arati Joshi
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium
Liraz Shay
 
Lean Quality & Engineering
Lean Quality & EngineeringLean Quality & Engineering
Lean Quality & Engineering
Mek Srunyu Stittri
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
Mindfire Solutions
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and Mocha
Atish Narlawar
 
Role of Automation in Testing
Role of Automation in TestingRole of Automation in Testing
Role of Automation in Testing
Anand Bagmar
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
123abcda
 
Refactoring page objects The Screenplay Pattern
Refactoring page objects   The Screenplay Pattern Refactoring page objects   The Screenplay Pattern
Refactoring page objects The Screenplay Pattern
RiverGlide
 
Bulletproof design systems using storybook
Bulletproof design systems using storybookBulletproof design systems using storybook
Bulletproof design systems using storybook
Chen Feldman
 
Contributing to open source
Contributing to open sourceContributing to open source
Contributing to open source
Devin Abbott
 
What’s new in Visual Studio 2012 & .NET 4.5
What’s new in Visual Studio 2012 & .NET 4.5What’s new in Visual Studio 2012 & .NET 4.5
What’s new in Visual Studio 2012 & .NET 4.5
Robert MacLean
 
Behavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shiftBehavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shift
Aspire Systems
 
HotelQuickly Product & Engineering
HotelQuickly Product & EngineeringHotelQuickly Product & Engineering
HotelQuickly Product & Engineering
Michal Juhas
 
Integration Testing in AEM
Integration Testing in AEMIntegration Testing in AEM
Integration Testing in AEM
connectwebex
 
Getting Started With Cypress
Getting Started With CypressGetting Started With Cypress
Getting Started With Cypress
Knoldus Inc.
 
Test Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and MochaTest Automation With Cucumber JVM, Selenium, and Mocha
Test Automation With Cucumber JVM, Selenium, and Mocha
Salesforce Developers
 
Automated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choiceAutomated Acceptance Tests & Tool choice
Automated Acceptance Tests & Tool choice
toddbr
 
Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkin
Arati Joshi
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium
Liraz Shay
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
Mindfire Solutions
 
Bdd with Cucumber and Mocha
Bdd with Cucumber and MochaBdd with Cucumber and Mocha
Bdd with Cucumber and Mocha
Atish Narlawar
 
Role of Automation in Testing
Role of Automation in TestingRole of Automation in Testing
Role of Automation in Testing
Anand Bagmar
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
123abcda
 
Refactoring page objects The Screenplay Pattern
Refactoring page objects   The Screenplay Pattern Refactoring page objects   The Screenplay Pattern
Refactoring page objects The Screenplay Pattern
RiverGlide
 
Bulletproof design systems using storybook
Bulletproof design systems using storybookBulletproof design systems using storybook
Bulletproof design systems using storybook
Chen Feldman
 
Contributing to open source
Contributing to open sourceContributing to open source
Contributing to open source
Devin Abbott
 
What’s new in Visual Studio 2012 & .NET 4.5
What’s new in Visual Studio 2012 & .NET 4.5What’s new in Visual Studio 2012 & .NET 4.5
What’s new in Visual Studio 2012 & .NET 4.5
Robert MacLean
 
Behavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shiftBehavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shift
Aspire Systems
 
HotelQuickly Product & Engineering
HotelQuickly Product & EngineeringHotelQuickly Product & Engineering
HotelQuickly Product & Engineering
Michal Juhas
 

Similar to Test Driven Development in AEM/CQ5 (20)

Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
Brett Child
 
UPC Plone Testing Talk
UPC Plone Testing TalkUPC Plone Testing Talk
UPC Plone Testing Talk
Timo Stollenwerk
 
Effective TDD - Less is more
Effective TDD - Less is moreEffective TDD - Less is more
Effective TDD - Less is more
Ben Lau
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
Gianluca Padovani
 
Reliable mobile test automation
Reliable mobile test automationReliable mobile test automation
Reliable mobile test automation
Vishal Banthia
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
Rogério Vicente
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
Xavi Hidalgo
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
Adam Doyle
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
wesovi
 
Spock pres
Spock presSpock pres
Spock pres
elizhender
 
TDD in Go with Ginkgo and Gomega
TDD in Go with Ginkgo and GomegaTDD in Go with Ginkgo and Gomega
TDD in Go with Ginkgo and Gomega
Eddy Reyes
 
How to establish ways of working that allows shifting-left of the automation ...
How to establish ways of working that allows shifting-left of the automation ...How to establish ways of working that allows shifting-left of the automation ...
How to establish ways of working that allows shifting-left of the automation ...
Max Barrass
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integration
haochenglee
 
Test-Driven Development.pptx
Test-Driven Development.pptxTest-Driven Development.pptx
Test-Driven Development.pptx
Tomas561914
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
Lars Thorup
 
Getting started with karate dsl
Getting started with karate dslGetting started with karate dsl
Getting started with karate dsl
Knoldus Inc.
 
Test driven development - Zombie proof your code
Test driven development - Zombie proof your codeTest driven development - Zombie proof your code
Test driven development - Zombie proof your code
Pascal Larocque
 
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS app
Aleks Zinevych
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
Peter Kofler
 
Getting started with unit and functional testing
Getting started with unit and functional testingGetting started with unit and functional testing
Getting started with unit and functional testing
Adewale Andrade
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
Brett Child
 
Effective TDD - Less is more
Effective TDD - Less is moreEffective TDD - Less is more
Effective TDD - Less is more
Ben Lau
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
Gianluca Padovani
 
Reliable mobile test automation
Reliable mobile test automationReliable mobile test automation
Reliable mobile test automation
Vishal Banthia
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
Rogério Vicente
 
Unit Testing and TDD 2017
Unit Testing and TDD 2017Unit Testing and TDD 2017
Unit Testing and TDD 2017
Xavi Hidalgo
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
Adam Doyle
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
wesovi
 
TDD in Go with Ginkgo and Gomega
TDD in Go with Ginkgo and GomegaTDD in Go with Ginkgo and Gomega
TDD in Go with Ginkgo and Gomega
Eddy Reyes
 
How to establish ways of working that allows shifting-left of the automation ...
How to establish ways of working that allows shifting-left of the automation ...How to establish ways of working that allows shifting-left of the automation ...
How to establish ways of working that allows shifting-left of the automation ...
Max Barrass
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integration
haochenglee
 
Test-Driven Development.pptx
Test-Driven Development.pptxTest-Driven Development.pptx
Test-Driven Development.pptx
Tomas561914
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
Lars Thorup
 
Getting started with karate dsl
Getting started with karate dslGetting started with karate dsl
Getting started with karate dsl
Knoldus Inc.
 
Test driven development - Zombie proof your code
Test driven development - Zombie proof your codeTest driven development - Zombie proof your code
Test driven development - Zombie proof your code
Pascal Larocque
 
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS app
Aleks Zinevych
 
Writing Tests with the Unity Test Framework
Writing Tests with the Unity Test FrameworkWriting Tests with the Unity Test Framework
Writing Tests with the Unity Test Framework
Peter Kofler
 
Getting started with unit and functional testing
Getting started with unit and functional testingGetting started with unit and functional testing
Getting started with unit and functional testing
Adewale Andrade
 
Ad

Recently uploaded (20)

Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Ad

Test Driven Development in AEM/CQ5

  • 2. What’s on the plate? ● What is Test driven development (TDD)? ● Why TDD / BDD? ● CQ backend and Spock testing framework ● Live code
  • 3. Not on the plate ● Advanced testing techniques ○ Features of Spock Framework ● Much about testing your UI / JS
  • 4. ● Software Consultant II / Tech lead ● WEM Consultant ○ Backend development ○ Comfortable with Java (/JSP) and Groovy ● I don’t dislike front-end development :-) About me
  • 5. I became a programmer because of the ‘science’ in programming, but, I remained a programmer because of the ‘art’ in programming. I believe..
  • 6. Some people have very strong opinions about this...
  • 8. Test Driven Development ● Write Test First (extreme programming) ○ Technical meaning ○ Design your code around the tests ● Write a lot of tests ○ Milder approach
  • 9. What is a Unit Test in CQ/AEM?
  • 10. Benefits of Testing ● Find bugs early ● Make it easy for a new person on your project ○ Read the tests if you don’t understand the code ● Improve code quality
  • 11. Benefits of Testing ● Helps during code re-factoring ● A good test is worth a thousand comments ● Executable documentation
  • 12. BDD ● Behavior Driven Development ● Writing tests from the customer’s / stakeholder’s point of view ● It really is TDD done well! ● More expressive than TDD
  • 13. //Variables expected, v1, v2, .. //Execute feature actual = System.executeFeature(v1, v2, ..) //The system gives output as expected assert actual == expected
  • 15. CQ/AEM and Spock ● What is Spock Framework? [ link ] ● Why is it awesome? [ link ] [ link ] ○ Is beautiful ● It can be used to test your CQ/AEM backend!
  • 16. A basic Spock Feature //Spock ‘feature’ def "My component should just work"() { given: final variables = [ //initial conditions ] final expected = new MyComponent(...) when: final actual = MyComponent.create(variables) then: actual == expected }
  • 17. Time for some real code... What ‘new’ will we see? ● Mocks in spock ● setupSpec(), cleanupSpec() ● @Ignore(), @Shared
  • 18. What all can you do? ● Unit tests for servlets, services ● Integration tests ● Functional tests for your rest APIs ● Even UI tests! (with Geb)
  • 19. What all can you do? Test Automation
  • 20. Where to go from here? ● Don’t have to start big ● Add tests to the code that is important, needs change ● Start new implementations with TDD
  • 21. The art of programming!