Test Driven Development in AEM/CQ5

  • View
    672

  • Download
    1

Embed Size (px)

DESCRIPTION

Presentation from RTP AEM / CQ5 Meetup by Sagar Sane. This presentation provides some of the challenges and benefits of applying Test Driven Development principles to Adobe Experience Manager (AEM)/CQ5 based projects and overview of some of the tools and technologies, including Spock & Geb, which can be used for automating test cases & execution.

Text of Test Driven Development in AEM/CQ5

  • 1.TDD in CQ5/AEM Sagar Sane

2. Whats 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 dont 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... 7. No, REALLY! 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 dont 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 customers / stakeholders 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 14. 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! 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. Time for some real code... What new will we see? Mocks in spock setupSpec(), cleanupSpec() @Ignore(), @Shared 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. What all can you do? Test Automation 19. Where to go from here? Dont have to start big Add tests to the code that is important, needs change Start new implementations with TDD 20. The art of programming! 21. Thank you!