3

I'm new in the area of software developing, and want to extend my knowledge over automation testing. I read a lot for Geb and Spock testing frameworks, but did not come to the conclusion for what purpose are they.

Am I correct:

Geb is for Page Objects (static covering the UI pages selectors, elements, etc.)

Spock is for writing the test order (Cases/Steps for test) (also is able to run API tests as well, mock data, parameterised endpoints, values and etc.)

--> What other differences they have? I already checked both documentations, but cannot understand.

I will appreciate every practical advice or example, differences between both as well, because I covered a lot of things, but there are only theoretical examples, but the main catch I did not get it.

Thank you in advance!

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
Yan Kennedy
  • 33
  • 1
  • 3
  • 1
    Geb is a framework to simplify Browser testing. If you don't use Geb with your tests, you need to use something like Selenium. Geb integrates very nicely with Spock, which as you say is a complete test framework for unit/integration testing your code – tim_yates Jun 24 '19 at 17:18

2 Answers2

4

Geb is a browser/web automation solution. You can use it to test the functionality of your web pages. Geb can automatically launch a web page, fill out form fields and click buttons on a web page. From the official website:

"It can be used for scripting, scraping and general automation — or equally as a functional/web/acceptance testing solution via integration with testing frameworks such as Spock, JUnit & TestNG."

The catch for Geb is web automation.

The catch for Spock is that it is testing and specification framework.

Examples

You can Geb to check the following:

  • When one opens mywebsite.com/login and enters a wrong username or password an error message should be displayed, say in a div.

  • When one opens mywebsite.com/submitData, fills in item name and price and clicks on the submit button, expect a message to show like "Thank you, the total number of items is now 5"

Trevor
  • 177
  • 5
1

GEB is build on top of WebDriver library and is compatible all the Browsers and Drivers which work with WebDriver.

Most commonly used way of achieving UI automation is though implementation of Page Object Model design pattern, Geb supports Page Object Model by implementing all the boiler plate code in its 'Page' class. The custom pages in an Automation Framework are required to extend this 'Page' class in order to access ready made functions and closures. Some Additional points:

  • It uses jQuery-ish navigator API to identify elements on the page.

  • There is a ready made 'js' object which lets you execute JavaScripts on your page.

  • There are closures which let you switch to another Window/iFrame/Alert of your webpage
  • Simplified handling of Dropdowns,Radio buttons,File Uploads,Checkboxes etc.
  • Introduces 'Interact' blocks which builds and perform the user actions (by utilizing Action class of Selenium WebDriver API)
  • geb.config file allows the developer to add support for multiple environments , drivers, Reporting , waiting etc.

Read more about Geb in the The Book of Geb

SPOCK on the other hand is a BDD Testing and Specification Framework inspired from frameworks like JUnit, jMock, RSpec, Groovy, Scala, Vulcans etc.

SPOCK is highly compatible with Geb and provides a 'GebReportingSpec' class which is required to be extended by the test classes in order to establish compatibility with Geb

Nikhil
  • 43
  • 7