DevQA: make your testers happier with Groovy, Spock and Geb
-
Upload
alvaro-sanchez-mariscal -
Category
Technology
-
view
1.562 -
download
0
description
Transcript of DevQA: make your testers happier with Groovy, Spock and Geb
![Page 1: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/1.jpg)
DevQA: make your testers happier with
Groovy, Spock and GebÁlvaro Sánchez-Mariscal
Web Architect – odobo !
@alvaro_sanchez
![Page 2: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/2.jpg)
About me
• Passionate software developer.
• Founded Salenda in 2005.
• Co-founded Escuela de Groovy in 2009.
• Groovy/Grails lover since 2007.
• Working now at Odobo as Web Architect.
![Page 3: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/3.jpg)
• HTML5 games platform for:
• Game developers.
• Casinos.
• We are hiring!
•http://bit.ly/odobo-grails-job
![Page 4: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/4.jpg)
DevOps
![Page 5: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/5.jpg)
DevQA
QA
![Page 6: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/6.jpg)
Writing tests in Grails
• Unit tests.
• Integration tests.
• Functional tests…
![Page 7: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/7.jpg)
Who should write the functional tests?
![Page 8: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/8.jpg)
Writing functional tests
• Normally, the Grails developers will write them.
• But if you have QA automation engineers…
![Page 9: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/9.jpg)
Problems we found at odobo and how we
solved them
![Page 10: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/10.jpg)
Disclaimer
One size does not fit all
![Page 11: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/11.jpg)
Problems we had
• Different frameworks used:
• Developers: Selenium IDE + Grails.
• QA: WebDriver + Java + TestNG.
• Duplicated efforts.
• Zero knowledge sharing and resources reuse.
![Page 12: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/12.jpg)
The approach
• Define a unified and shared testing framework for Dev and QA.
• For any kind of web application.
• Have N+M testers instead of N Devs and M QAs.
![Page 13: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/13.jpg)
The framework
• An independent project using:
• Gradle for building and running.
• Groovy as programming language.
• Spock as testing framework.
• Geb as browser automation tool.
• With some custom features.
![Page 14: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/14.jpg)
Independent project• Pros:
• Easier for non Grails developers.
• Prevents QA from touching anything else.
• We can now write tests for any application.
• Cons:
• You need to think about how to feed your app with fixture data.
![Page 15: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/15.jpg)
Fixtures
• First attempt: GORM standalone. It didn’t work :(
• We already had a fixture controller to allow Selenium IDE invocations via HTTP.
• It was easy to reuse in the new project.
• This requires to have the Grails application running.
![Page 16: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/16.jpg)
Fixtures: in Grails
![Page 17: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/17.jpg)
Fixtures: in Selenium IDE
![Page 18: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/18.jpg)
Fixtures: in Geb
![Page 19: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/19.jpg)
Jenkins gotchas
• There are 2 projects, so:
1. Run Grails app.
2. When it is up, launch the tests.
3. Tear down everything at the end.
![Page 20: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/20.jpg)
Solution: a custom script
![Page 21: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/21.jpg)
The language
• Pros:
• Strong knowledge within the Grails team.
• Less verbose than Java (aka “We are not writing fucking semicolons!”).
• Cons:
• Learning curve for QA automation engineers.
![Page 22: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/22.jpg)
The testing framework
• Pros:
• Beautiful DSL, even better combined with Geb.
• Cons:
• Low IDE support.
![Page 23: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/23.jpg)
The browser tool
• Pros:
• Awesome DSL.
• Cons:
• Very difficult to “try and error” your CSS selectors.
• You end debugging and evaluating expressions.
![Page 24: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/24.jpg)
Porn for developers!
![Page 25: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/25.jpg)
Porn for developers!
![Page 27: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/27.jpg)
Configuration
• Groovy’s ConfigSlurper inside.
• Per environment, like in Grails.
![Page 28: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/28.jpg)
Configuration
![Page 29: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/29.jpg)
Per environment execution
• We have 2 kinds of environments:
• With fixtures enabled, like localhost.
• Live environments, like QA or Staging.
• Implemented as a Spock extension.
![Page 30: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/30.jpg)
Per environment execution
![Page 31: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/31.jpg)
Feature Groups
• A port of TestNG’s test groups.
• Used by QA team to group tests around business features, and not just single user stories.
• Eg: @FeatureGroup([‘operatorMarketplace’])
• Implemented as a Spock extension.
![Page 32: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/32.jpg)
Feature Groups
![Page 33: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/33.jpg)
Feature Groups
![Page 34: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/34.jpg)
Conclusions
• Happier Grails developers.
• The whole solution is better than Selenium IDE.
• Happier QA’s.
• Learning a lot of new stuff.
• Not feeling alone anymore.
![Page 35: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/35.jpg)
Conclusions
• No effort duplication.
• Everybody works on the same project.
• Effective code reuse.
• CSS selectors are reused via Geb pages / modules.
![Page 36: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/36.jpg)
Developing SPI apps with Grails and Angular JS
This afternoon, 14:00
![Page 37: DevQA: make your testers happier with Groovy, Spock and Geb](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f5bb8b4c905524c8b5535/html5/thumbnails/37.jpg)
Thanks!Álvaro Sánchez-Mariscal
Web Architect – odobo !
@alvaro_sanchez