Simplified Test Automation Framework with Geb & Spock
Simplicity is prerequisite for reliability.
--Edsger W.Dijkstra
--Edsger W.Dijkstra
Simplified Test Automation with Geb
This post is about the Geb & Spock (Groovy)
automation framework which makes test automation extremely simple and powerful. It helps in
jump starting the test automation with all the cutting edge automation features
ready ...
On using GEB &
SPOCK framework, since beginning we are substantially far ahead compared to
typical Selenium Webdriver Frameworks implemented in Java which has some major issues and dilemmas as
discussed below in detail:
Using JAVA for TEST Automation….
1).Java is verbose
and very sophisticated and heavy language for the need of test automation .In
short it is an overkill to use java for test automation.
2).But Java is Powerful!!!
On the other hand Java is extremely robust
and powerful with tons of features like OOPS, which cannot be used/ implemented
holistically in scripting languages.
3).Unmatched Open
Source Support: Java is being the most popular web language, has the
virtually unlimited support for third party open source tools/utilities and
APIs which we may lose if we step away from Java…
So there is a dilemma, we want to leave Java being overkill
for test automation but at the same time it is full of features and with
unmatched open source support.
So is there a way, we can use Java
without actually using Java ???
Answer is Yes, Use Groovy.
·
- An agile and dynamic language for the Java Virtual Machine
- · Makes modern programming features available to java developers with low learning curve
- Provides the ability to statically type check and statically compile your code for robustness and performance
- Share base syntax, type system, packages hierarchy with Java
- Every Gradle build file is a groovy script
GEB Automation Framework:
Geb uses WebDriver to test web applications using either
real browsers or the HtmlUnit library. What
sets Geb apart from the competition is the jQuery-like syntax for querying your
HTML pages and its built-in support for the Page Object pattern.
So the answer we found after long research across multiple
tools/technologies is GEB.
GEB does all the heavy lifting under the hood and eases and
improves the productivity of an automation developer many folds..!!!
Highlights:
- · Power Of WebDriver
- · Elegance of jQuery Selection
- · Robustness of Page Object Modelling
- · Expressiveness of Groovy
A typical GEB automation script... |
The simple, elegant & intuitive scripting as above,
makes test automation really easy ,fast and above all effective which further makes
test automation maintenance simpler to update as required with minimal technical
complexity which is really an aid as the test automation grows in terms of size
and complexity over the period of time.
SPOCK : The combination of Groovy and GEB is really simple and elegant
but the real power comes when it is combined with SPOCK which is an Groovy
Unit testing framework (inspired from Junit) which adds lot of much required
features in test automation ,out of the box without compromising the overall
simplicity and design of Groovy and GEB framework.
There are couple of strong features which comes from SPOCK
but it is not a comprehensive list:
1).Data Driven
Testing utilising external data sources including text, CSV, excel &
databases.
2) .Comprehensive Extensible Multi-level status reporting in HTML,XML and plain
text formats
3).Detailed Logs and stack
traces for quick root cause analysis in Debugging
4).Power Assertions
5).Screenshot
Capturing & Screen scraping for capturing DOM structures for later
analysis.
Selenium Webdriver: Under the hood GEB
uses powerful selenium webdriver APIs which does not need any introduction in
the test automation world .In fact it has become the de facto standard across
industry. GEB uses the all the power inherit
in the selenium webdriver API without exposing the complexity to the end User.
Cross
Browser Support: The framework has been designed to specially
encounter the most pressing problem in test automation-Cross browser Support.
It supports execution on all the standard prevailing browser including IE, Firefox
and Chrome and more. It also supports headless browser execution for quick
turnaround for build verifications and smoke test suites.
Seamless
Integration With CI(Jenkins): It has been designed to support CI
execution which has been tested and proven with large scale test automation with
Jenkins which is the standard CI tool for the industry. In the same way it can be integrated with
other CI tools as it supports extensively multiple build tools including Maven
& Gradle which helps to provide plug and play solutions for most CI test environments.
Cloud
Based Test Execution With Browser Stack & Sauce Labs: It
has been completely integrated with BrowserStack & saucelabs, which can be utilized over
the air for quick build verifications or large automation suite in any desired environment
having support for Cross Platform and cross browsers including Windows, MAC,
Linux with IE, Firefox and Chrome browsers.
Maven: Apache Maven is a software project
management and comprehension tool. Based on the concept of a project object
model (POM), Maven can manage a project's build, reporting and documentation
from a central piece of information.
This Framework supports complete automation building, dependency
management and project creation using Maven which can also be utilized for
smooth CI as well as local execution setups across multiple systems.
Gradle : is a project automation tool that builds upon
the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific
language (DSL) instead of the more traditional XML form of declaring the
project configuration. Gradle takes the build automation capability to next
level from the Ant & Maven with the grace and easiness of Groovy.
This framework works with Gradle completely and can be
integrated with variety of tools further using Gradle seamlessly and quickly.
Conclusion: Synergy which comes
with integration of all these tools & components, significantly helps to
jump start the test automation in most of the settings right away which in turn
accelerate the overall testing process.
Comments