Skip to content

Instantly share code, notes, and snippets.

@restagner
restagner / TestMasterLicenseGORMAssociations.groovy
Created March 13, 2015 15:22
A Groovy script using stand-alone GORM along with entities generated with Grails' db-reverse-engineer plugin
@Grab("org.grails:gorm-hibernate4-spring-boot:1.1.0.RELEASE")
@Grab("Microsoft:mssql-driver-jdbc4:4.0")
@GrabExclude('org.codehaus.groovy:groovy-all')
import grails.persistence.*
import grails.orm.bootstrap.*
import com.microsoft.sqlserver.jdbc.SQLServerDriver
import org.springframework.jdbc.datasource.DriverManagerDataSource
@Grab("org.grails:gorm-hibernate4-spring-boot:1.1.0.RELEASE")
@Grab("Microsoft:mssql-driver-jdbc4:4.0")
@GrabExclude('org.codehaus.groovy:groovy-all')
import grails.persistence.*
import grails.orm.bootstrap.*
import com.microsoft.sqlserver.jdbc.SQLServerDriver
import org.springframework.jdbc.datasource.DriverManagerDataSource
@restagner
restagner / AccessorsExample
Created March 24, 2014 18:31
An example script that attempts to use multiple instances of the @DeleGate annotation
@Grapes (
[@Grab("org.seleniumhq.selenium:selenium-java:2.40.0")
, @Grab("org.seleniumhq.selenium:selenium-support:2.40.0")])
import org.openqa.selenium.WebDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.support.PageFactory
import org.openqa.selenium.support.FindBy
import org.openqa.selenium.By
import org.openqa.selenium.WebElement
@restagner
restagner / stacktrace.txt
Last active August 29, 2015 13:56
Could not find matching constructor stack trace
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: myplace.dsl.DmaDSL(myplace.steps.support.TestEnvironment)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1601)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1404)
at org.codehaus.groovy.runtime.callsite.MetaClassConstructorSite.callConstructor(MetaClassConstructorSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
at myplace.steps.support.DMAWorld.<init>(env.groovy:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
@restagner
restagner / DmaDSL.groovy
Created March 3, 2014 21:43
Class being called from within env.groovy
...
class DmaDSL {
private final WebDriver driver
private final TestEnvironment testEnvironment
...
DmaDSL(TestEnvironment tstEnv) {
testEnvironment = tstEnv
driver = testEnvironment.driver
@restagner
restagner / env.groovy
Last active August 29, 2015 13:56
Example of env script for Groovy
package myplace.steps.support
import cucumber.runtime.ScenarioImpl
import cucumber.api.groovy.Hooks
import org.openqa.selenium.OutputType
import org.openqa.selenium.TakesScreenshot
import org.openqa.selenium.WebDriver
import myplace.dsl.DmaDSL
this.metaClass.mixin(Hooks)
@restagner
restagner / env.groovy
Created January 29, 2014 14:49
Example of Cucumber env settings in Groovy
package cucumber.support
import cucumber.api.groovy.Hooks
import cucumber.helpers.MyHelper
this.metaClass.mixin(Hooks)
class CucumberWithGroovyWorld {
@Delegate MyHelper myHelper
@Delegate TestEnvironment testEnvironment
@restagner
restagner / BasicArithmeticSteps.groovy
Created January 29, 2014 14:47
Example of Cucumber Steps written in Groovy
package cucumber.steps
import cucumber.api.DataTable
import cucumber.support.CucumberWithGroovyWorld
import org.stag.qa.Calculator
import static cucumber.api.groovy.EN.*
import static cucumber.api.groovy.Hooks.Before
CucumberWithGroovyWorld world
@restagner
restagner / pom.xml
Created September 17, 2013 23:46
A pom.xml file for my groovy project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.groovy.example</groupId>
<artifactId>groovymeta-example</artifactId>
<version>1.0-SNAPSHOT</version>
@restagner
restagner / Example Scenario Outline.feature
Created November 17, 2012 21:36
Sample Cucumber feature used by Natural Eclipse plugin
Scenario Outline: This is an example of a scenario outline
Given this is a scenario outline
When we concatenate <string_1> with <string_2>
Then the combined string is <string_3>
Examples:
|string_1 | string_2 | string_3 |
| hello | world | helloworld |
| good | bye | goodbye |