Showing posts with label Spock. Show all posts
Showing posts with label Spock. Show all posts

October 18, 2016

Testing The-Internet with Geb + Groovy + Spock: About Yeoman, scaffolding, and other build tools

Have you ever needed to set up a brand-new project but were not sure where to start? I am like that right now!

For the past week, I have been trying to figure out how I wanted to set up the file and folder structure for a new Geb + Groovy + Gradle + Spock project. I was going to go back to Dave Haeffner's test site, The-Internet ( link ) and take a look at writing a test for his login page:

  • Geb (pronounced "jeb") is a mash-up of jQuery, Selenium WebDriver, with the Page Object Model, Reporting, and taking Snapshots built in. 
  • Groovy is a scripting language language that I covered before in my blog, specifically when talking about using Gradle for build.gradle configurations. 
  • Gradle does a lot more than handle installing third-party dependencies such as Chromedriver when you want to spin up a new Chrome browser on your local machine. With Gradle, you can set up tests to be kicked off on the command line, just waiting to be fed into a continuous integration environment such as Jenkins.  
  • The Spock Framework follows a Given / Then / When / Expect framework found in Cucumber's Gherkin language format that is usually paired with Ruby
But how do I set all these tools up if I want to test ? How to get them all to work together?

Should I just repurpose Sauce Labs Test Framework, Groovy-Geb-Spock-Selenium at https://github.com/saucelabs-sample-test-frameworks/Groovy-Geb-Spock-Selenium?

A new co-worker of mine referred me to a tool he had heard of at a previous job that may help: Yeoman.io.




In the next blog article, we will be borrowing heavily from "Let's Scaffold a Web App" written by Mehdy Dara ( Github: zckers ) to walk through setting up your Mac or PC for Yeoman. We will also walk through installing a Geb Generator for Yeoman created by Chris Hluchan ( LinkedIn ), a Software Engineer at Google, formerly at Oracle. This will set up the project's scaffolding.

Later articles will talk about about:

  • Diving into the scaffolding code that has been generated, figuring out how it works
  • How to set up the Gradle configuration file to be able to run tests in parallel
  • Customizing the scaffolding to work with a login page
  • How Geb works with Selenium WebDriver: entering text, clicking buttons, and capturing web elements in page objects. 
This blog article will talk a bit about the history of the Yeoman tool.