/tapestry-geb

Utilities for Geb-based browser tests of Tapestry applications

Primary LanguageJavaApache License 2.0Apache-2.0

tapestry-geb Build Status

Use Geb (http://www.gebish.org/) to test Tapestry (http://tapestry.apache.org/) web applications.

This library provides basic integration for testing Tapestry webapps with Geb. The original idea was cheekily stolen from https://tawus.wordpress.com/2012/08/03/spock-runjetty/.

Usage

A basic usage example to load an application's Index page and check the page title.

build.gradle:

repositories {
  jcenter()
}

dependencies {
  testCompile 'de.eddyson:tapestry-geb:0.41.1'
  testCompile "org.seleniumhq.selenium:selenium-firefox-driver:3.8.1"
}


tasks.withType(Test){
  systemProperty 'tapestry.execution-mode', 'test'
  systemProperty 'jettyPort', 9023
  systemProperty 'webappLocation', 'src/main/webapp'
  systemProperty 'geb.env', 'firefox'
}

src/test/groovy/GebConfig.groovy:

import org.openqa.selenium.firefox.FirefoxDriver

reportsDir = 'build/reports/geb'
baseUrl = "http://localhost:${System.properties['jettyPort']}/"
environments {
  firefox {
    driver = { new FirefoxDriver() }
  }
}

src/test/groovy/org/exaple/app/integration/SimpleTest.groovy:

package org.example.app.integration

import de.eddyson.tapestrygeb.JettyGebSpec

class SimpleTest extends JettyGebSpec {

  def "Load index page"(){
    when:
      go page
    then:
      title == "Example application"
  }
}