You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Barry Books <tr...@gmail.com> on 2013/08/30 22:28:54 UTC

Godzilla's Guide to Gradle/Geb

I'm no expert, in fact this is my first Gradle/Geb project. The following
works for me with 5.4 alpha:

With the Eclipse Gradle plugin I can do a Gradle build which runs the tests
and creates a war file.

create a build.gradle file with this

apply plugin: 'java'

apply plugin: 'war'

apply plugin: 'jetty'

apply plugin: 'eclipse-wtp'

apply plugin: 'groovy'

apply plugin: 'maven'



 project.ext.versions = [

    jetty: "7.6.11.v20130520",

    tomcat: "6.0.30",

    testng: "6.5.2",

    easymock: "3.0",

    servletapi: "2.5",

    spock: "0.7-groovy-2.0",

    hibernate: "4.1.2.Final",

    groovy: "2.0.6",

    slf4j: "1.7.2",

    wro4j: "1.7.0",

    geb: "0.9.0",

    selenium: "2.33.0"

]


repositories {

  mavenCentral()

  maven {

        url "https://repository.apache.org/content/groups/staging"

    }

}


dependencies {

compile 'org.apache.tapestry:tapestry-core:5.4-alpha-15'

compile 'org.apache.tapestry:tapestry-test:5.4-alpha-15'

    compile 'org.apache.tapestry:tapestry-runner:5.4-alpha-15'

compile 'com.paypal.sdk:rest-api-sdk:0.5.2'

runtime 'javax.servlet:jstl:1.1.2'

providedCompile 'javax.servlet:servlet-api:2.5'

testRuntime "org.slf4j:slf4j-log4j12:${versions.slf4j}"

groovy "org.codehaus.groovy:groovy-all:${versions.groovy}"

testCompile "org.gebish:geb-spock:${versions.geb}"

    testCompile "org.spockframework:spock-core:${versions.spock}"

    testCompile
"org.seleniumhq.selenium:selenium-java:${versions.selenium}", {

        exclude group: "org.eclipse.jetty"

    }

    testCompile
"org.seleniumhq.selenium:selenium-server:${versions.selenium}", {

        exclude group: "org.eclipse.jetty"

    }

}


test {

useJUnit()

systemProperties("geb.build.reportsDir": "$reporting.baseDir/geb",

        "tapestry.compiled-asset-cache-dir":
"$buildDir/compiled-asset-cache",

        "tapestry.production-mode": "false")

}


in src/test/resources/GebConfig.groovy


driver = "firefox"


baseUrl = "http://localhost:8080/sandbox"


waiting {

  // Long timeout since we have to wait for Rhino & friends to spin up

  timeout = 60

}


in src/test/groovy/tests/IndexTest.groovy


package tests


import geb.spock.GebReportingSpec

import org.apache.tapestry5.test.Jetty7Runner

import spock.lang.Shared


class IndexTest extends GebReportingSpec {


 @Shared

def runner;


 def setupSpec() {

runner = new Jetty7Runner("src/main/webapp", "/sandbox", 8080, 8081);

runner.start()

}


 def cleanupSpec() {

runner.stop()

}



 def "Check Index"() {

when:

// Open index page

go()

then:

$(".title").text().trim() == "Index"

}

 def "Check Button"() {

when:

// Open index page

go()

then:

$(".btn").value().trim() == "Create/Update"

}

}