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!

More Related Content

PPTX
Test Driven Development in CQ5/AEM
PDF
Using The Page Object Pattern
PDF
Perils of Page-Object Pattern
PPT
Automated Testing With Jasmine, PhantomJS and Jenkins
PPTX
Introduction to Bdd and cucumber
PDF
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
PDF
Cucumber ppt
PPT
Intro to Service Worker API and its use cases
Test Driven Development in CQ5/AEM
Using The Page Object Pattern
Perils of Page-Object Pattern
Automated Testing With Jasmine, PhantomJS and Jenkins
Introduction to Bdd and cucumber
DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)
Cucumber ppt
Intro to Service Worker API and its use cases

What's hot (20)

PPTX
Test Automation Framework with BDD and Cucumber
PDF
Integration Testing in AEM
PPTX
Polyglot engineering
PDF
Getting Started With Cypress
PPT
Test Automation With Cucumber JVM, Selenium, and Mocha
PPTX
Automated Acceptance Tests & Tool choice
PPTX
Cucumber BDD
PPTX
Bdd – with cucumber and gherkin
PPTX
BDD with SpecFlow and Selenium
PDF
Lean Quality & Engineering
ODP
Test Automation Framework using Cucumber BDD overview (part 1)
PPTX
Bdd with Cucumber and Mocha
PDF
Role of Automation in Testing
PPTX
Automation test framework with cucumber – BDD
PPTX
Refactoring page objects The Screenplay Pattern
PPTX
Bulletproof design systems using storybook
PDF
Contributing to open source
PPTX
What’s new in Visual Studio 2012 & .NET 4.5
PDF
Behavior Driven Testing - A paradigm shift
PPTX
HotelQuickly Product & Engineering
Test Automation Framework with BDD and Cucumber
Integration Testing in AEM
Polyglot engineering
Getting Started With Cypress
Test Automation With Cucumber JVM, Selenium, and Mocha
Automated Acceptance Tests & Tool choice
Cucumber BDD
Bdd – with cucumber and gherkin
BDD with SpecFlow and Selenium
Lean Quality & Engineering
Test Automation Framework using Cucumber BDD overview (part 1)
Bdd with Cucumber and Mocha
Role of Automation in Testing
Automation test framework with cucumber – BDD
Refactoring page objects The Screenplay Pattern
Bulletproof design systems using storybook
Contributing to open source
What’s new in Visual Studio 2012 & .NET 4.5
Behavior Driven Testing - A paradigm shift
HotelQuickly Product & Engineering
Ad

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

PPTX
Test-driven development & Behavior-driven development basics
PDF
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
PDF
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
PDF
TDD for Testers Workshop
PDF
I am afraid of no test! The power of BDD
PPT
Test Driven Development using QUnit
PPTX
Test driven development v1.0
PPTX
Understanding TDD - theory, practice, techniques and tips.
PDF
Test first!
PPTX
TDD - Seriously, try it! - Opensouthcode
PPTX
TDD - Seriously, try it - Codemotion (May '24)
PDF
TDD and BDD and ATDD
PPTX
Test Driven Development - a Practitioner’s Perspective
PDF
Test driven development : software process
PPT
Tech talks #1- Unit testing and TDD
PDF
Test Driven Development
PDF
Test Driven Development (TDD) on Force.com projects
PPT
Test Driven Development - Overview and Adoption
PDF
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
PPTX
Cleaner Code Through Test-Driven Development
Test-driven development & Behavior-driven development basics
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
TDD for Testers Workshop
I am afraid of no test! The power of BDD
Test Driven Development using QUnit
Test driven development v1.0
Understanding TDD - theory, practice, techniques and tips.
Test first!
TDD - Seriously, try it! - Opensouthcode
TDD - Seriously, try it - Codemotion (May '24)
TDD and BDD and ATDD
Test Driven Development - a Practitioner’s Perspective
Test driven development : software process
Tech talks #1- Unit testing and TDD
Test Driven Development
Test Driven Development (TDD) on Force.com projects
Test Driven Development - Overview and Adoption
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Cleaner Code Through Test-Driven Development
Ad

Recently uploaded (20)

PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
A Presentation on Artificial Intelligence
PPT
Teaching material agriculture food technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Encapsulation theory and applications.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Modernizing your data center with Dell and AMD
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
A Presentation on Artificial Intelligence
Teaching material agriculture food technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Empathic Computing: Creating Shared Understanding
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Encapsulation theory and applications.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
NewMind AI Monthly Chronicles - July 2025
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Spectral efficient network and resource selection model in 5G networks
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
Modernizing your data center with Dell and AMD

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!