With application and team growth such questions as keeping documentation up to date, sharing of the knowledge, communication between stakeholder and development team became more and more actual. BDD as methodology is aimed to minimize negative impact of those issues. Spock and Geb frameworks will help us to illustrate BDD implementation on specific example.
1 of 78
Downloaded 25 times
More Related Content
2014 Jeeconf - Geb Spock
1. BDD and browser automation with
Geb and Spock
舒仆亳仍ミ 仂亞亟舒仆
Jeeconf | may 2014 | @bogdand
48. Spock 亠
class GoogleSpec extends GebReportingSpec {
def "the first link should be wikipedia"() {
when:
to GoogleHomePage
q = "wikipedia"
then:
at GoogleResultsPage
firstResultLink.text() == "Wikipedia"
when:
firstResultLink.click()
then:
waitFor { at WikipediaPage }
}
}
49. Spock data-driven 亠
when:
LoginPage loginPage = loginAsUser(username)
then:
assert loginPage.error == expectedErrorMessage
where:
username | expectedErrorMessage
'disabledUser' | 'Sorry, your account is disabled'
'lockedUser' | 'Sorry, your account is locked'
'invalidUser' | 'Sorry, we could not find that account'
51. 亠从舒亳于亶 亠
class LoginSpec extends GebReportingSpec {
def "login"() {
given: "a valid user"
go RegistrationPage
register("user", "password")
logout()
when: "the user logins with valid credentials"
go LoginPage
login("user", "password")
then: "the welcome page is displayed"
at DashboardPage
}
52. 亠从舒亳于亶 亠
class LoginSpec extends GebReportingSpec {
def "login"() {
given: "a valid user"
go RegistrationPage
register("user", "password")
logout()
when: "the user logins with valid credentials"
go LoginPage
login("user", "password")
then: "the welcome page is displayed"
at DashboardPage
}
57. Remote control
Groovy remote control
is a library for executing closures defined in one
Groovy application to be executed in a different
(possible remote) Groovy application.
58. Remote control - 亠于亠
def receiver = new Receiver()
def handler = new RemoteControlHttpHandler(receiver)
def server =
HttpServer.create(new InetSocketAddress(8080), 0)
server.createContext("/groovy-rc", handler)
server.start()
59. Remote control - 亠于亠
def receiver = new Receiver()
def handler = new RemoteControlHttpHandler(receiver)
def server =
HttpServer.create(new InetSocketAddress(8080), 0)
server.createContext("/groovy-rc", handler)
server.start()
60. Remote control - 亠于亠
def receiver = new Receiver()
def handler = new RemoteControlHttpHandler(receiver)
def server =
HttpServer.create(new InetSocketAddress(8080), 0)
server.createContext("/groovy-rc", handler)
server.start()
61. Remote control - 从仍亳亠仆
def transport =
new HttpTransport("http://example.org:8080/groovy-rc")
def remote = new RemoteControl(transport)
def id = remote {
def user = new User(name: "Me", password: "pwd")
user.save()
user.id
}
62. Remote control - 从仍亳亠仆
def transport =
new HttpTransport("http://example.org:8080/groovy-rc")
def remote = new RemoteControl(transport)
def id = remote {
def user = new User(name: "Me", password: "pwd")
user.save()
user.id
}
63. Remote control - 从仍亳亠仆
def transport =
new HttpTransport("http://example.org:8080/groovy-rc")
def remote = new RemoteControl(transport)
def id = remote {
def user = new User(name: "Me", password: "pwd")
user.save()
user.id
}
64. Remote control - 从仍亳亠仆
def transport =
new HttpTransport("http://example.org:8080/groovy-rc")
def remote = new RemoteControl(transport)
def id = remote {
def user = new User(name: "Me", password: "pwd")
user.save()
user.id
}
65. 亠从舒亳于亶 亠
class LoginSpec extends GebReportingSpec {
def "login"() {
given: "a valid user"
go RegistrationPage
register("user", "password")
logout()
when: "the user logins with valid credentials"
go LoginPage
login("user", "password")
then: "the welcome page is displayed"
at DashboardPage
}
66. 舒亳于亶 亠
class LoginSpec extends GebReportingSpec {
def "login"() {
given: "a valid user"
remote {
SpringUtils.getRegisterService()
.register("user", "password")
}
when: "the user logins with valid credentials"
go LoginPage
login("user", "password")
then: "the welcome page is displayed"
at DashboardPage
76. class InviteesSpec extends GebBaseSpec {
def "Invitee should get a free payment"() {
when: "registered with invite link user"
registeredWithInviteLinkUser()
then: "user has one free payment"
to AccountPage
freePayments.text().contains("1")
}
}