Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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
● ...
Not on the plate
● Advanced testing techniques
o Features of Spock Framework
● Much about testing your UI / JS
● Software Consultant II / Tech lead
● WEM Consultant
o Backend development
o Comfortable with Java (/JSP) and Groovy
● I ...
I became a programmer because of the
‘science’ in programming,
but, I remained a programmer because of the
‘art’ in progra...
Some people have very strong opinions about this...
No, REALLY!
Test Driven Development
● Write Test First (extreme programming)
o Technical meaning
o Design your code around the tests
●...
What is a Unit Test in CQ/AEM?
Benefits of Testing
● Find bugs early
● Make it easy for a new person on your
project
o Read the tests if you don’t unders...
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 don...
//Variables
expected, v1, v2, ..
//Execute feature
actual = System.executeFeature(v1, v2, ..)
//The system gives output as...
CQ/AEM and Spock
● What is Spock Framework? [ link ]
● Why is it awesome? [ link ] [ link ]
o Is beautiful
● It can be use...
A basic Spock Feature
//Spock ‘feature’
def "My component should just work"() {
given:
final variables = [ //initial condi...
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 ...
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 imple...
The art of programming!
Thank you!
Test Driven Development in CQ5/AEM
Upcoming SlideShare
Loading in …5
×

Test Driven Development in CQ5/AEM

2,028 views

Published on

In this talk, we will go over what TDD is? And what does it mean for CQ5/AEM development (in this case, primarily AEM's Backend architecture)

Published in: Software, Technology, Education
  • Be the first to comment

Test Driven Development in CQ5/AEM

  1. 1. TDD in CQ5/AEM Sagar Sane
  2. 2. What’s on the plate? ● What is Test driven development (TDD)? ● Why TDD / BDD? ● CQ backend and Spock testing framework ● Live code
  3. 3. Not on the plate ● Advanced testing techniques o Features of Spock Framework ● Much about testing your UI / JS
  4. 4. ● Software Consultant II / Tech lead ● WEM Consultant o Backend development o Comfortable with Java (/JSP) and Groovy ● I don’t dislike front-end development :-) About me
  5. 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. 6. Some people have very strong opinions about this...
  7. 7. No, REALLY!
  8. 8. Test Driven Development ● Write Test First (extreme programming) o Technical meaning o Design your code around the tests ● Write a lot of tests o Milder approach
  9. 9. What is a Unit Test in CQ/AEM?
  10. 10. Benefits of Testing ● Find bugs early ● Make it easy for a new person on your project o Read the tests if you don’t understand the code ● Improve code quality
  11. 11. Benefits of Testing ● Helps during code re-factoring ● A good test is worth a thousand comments ● Executable documentation
  12. 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. 13. //Variables expected, v1, v2, .. //Execute feature actual = System.executeFeature(v1, v2, ..) //The system gives output as expected assert actual == expected
  14. 14. CQ/AEM and Spock ● What is Spock Framework? [ link ] ● Why is it awesome? [ link ] [ link ] o Is beautiful ● It can be used to test your CQ/AEM backend!
  15. 15. 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 }
  16. 16. Time for some real code... What ‘new’ will we see? ● Mocks in spock ● setupSpec(), cleanupSpec() ● @Ignore(), @Shared
  17. 17. What all can you do? ● Unit tests for servlets, services ● Integration tests ● Functional tests for your rest APIs ● Even UI tests! (with Geb)
  18. 18. What all can you do? Test Automation
  19. 19. 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
  20. 20. The art of programming!
  21. 21. Thank you!

×