devqa: make your testers happier with groovy, spock and geb (greach 2014)

40
DevQA: make your testers happier with Groovy, Spock and Geb Álvaro Sánchez-Mariscal Web Architect odobo @alvaro_sanchez

Upload: alvaro-sanchez-mariscal

Post on 08-May-2015

1.180 views

Category:

Software


2 download

DESCRIPTION

Writing functional tests using Geb in a Grails application is fine for a development team. But when you have QA automation engineers, giving them access to the Grails app might not be the best solution (specially when they belong to a different team). So the same way DevOps allow developers and sysadmins collaborate together, let’s talk about DevQA, and make them happy using a framework stack powered by Groovy. Besides above considerations, in this talk I will show a live example on how to setup an independent project for functional tests using Gradle, Groovy, Spock and Geb.

TRANSCRIPT

Page 1: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 (Greach 2014)

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 (Greach 2014)

• HTML5 games platform for:

• Game developers.

• Casinos.

• Check out https://play.odobo.com and try for free!

Page 4: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

DevOps

Page 5: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

DevQA

QA

Page 6: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Writing tests in Grails

• Unit tests.

• Integration tests.

• Functional tests…

Page 7: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Who should write the functional tests?

Page 8: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 (Greach 2014)

Problems we found at odobo and how we

solved them

Page 10: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Disclaimer

One size does not fit all

Page 11: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 (Greach 2014)

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 (Greach 2014)

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 (Greach 2014)

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 (Greach 2014)

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 (Greach 2014)

Fixtures: in Grails

Page 17: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Fixtures: in Selenium IDE

Page 18: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Fixtures: in Geb

Page 19: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 (Greach 2014)

Solution: a custom script

Page 21: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 (Greach 2014)

The testing framework

• Pros:

• Beautiful DSL, even better combined with Geb.

• Cons:

• People that only have done JUnit may need more time to get used to BDD style.

Page 23: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 (Greach 2014)

The browser tool

• Cons:

• Lack of IDE support:

Page 25: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Porn for developers!

Page 26: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Porn for developers!

Page 27: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Documentation

In Confluence

Page 28: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Configuration

• Groovy’s ConfigSlurper inside.

• Per environment, like in Grails.

Page 29: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Configuration

Page 30: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 31: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Per environment execution

Page 32: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 33: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Feature Groups

Page 34: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Feature Groups

Page 35: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

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 36: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Conclusions

• No effort duplication.

• Everybody works on the same project.

• Effective code reuse.

• CSS selectors are reused via Geb pages / modules.

Page 37: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Conclusions

• Groovy is now being used also for REST API testing.

• Java developers are also being exposed to Groovy.

• … and one day it will take over the world!

Page 38: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Current research

• Use Sikuli to automate game testing.

• Sikuli is a visual technology to automate and test graphical user interfaces using screenshot images.

Page 39: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Sikuli

Page 40: DevQA: make your testers happier with Groovy, Spock and Geb (Greach 2014)

Thanks!Álvaro Sánchez-Mariscal

Web Architect – odobooo !

@alvaro_sanchez alvarosanchez