174 строки
5,9 КиБ
Gherkin
174 строки
5,9 КиБ
Gherkin
Feature: undefined step snippets
|
|
In order to implement step definitions faster
|
|
As a test suite user
|
|
I need to be able to get undefined step snippets
|
|
|
|
Scenario: should generate snippets
|
|
Given a feature "undefined.feature" file:
|
|
"""
|
|
Feature: undefined steps
|
|
|
|
Scenario: get version number from api
|
|
When I send "GET" request to "/version"
|
|
Then the response code should be 200
|
|
"""
|
|
When I run feature suite
|
|
Then the following steps should be undefined:
|
|
"""
|
|
I send "GET" request to "/version"
|
|
the response code should be 200
|
|
"""
|
|
And the undefined step snippets should be:
|
|
"""
|
|
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
|
// ---
|
|
|
|
|
|
func iSendRequestTo(arg1, arg2 string) { }
|
|
func theResponseCodeShouldBe(arg1 int) { }
|
|
|
|
ctx.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo)
|
|
ctx.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe)
|
|
"""
|
|
|
|
Scenario: should generate snippets with more arguments
|
|
Given a feature "undefined.feature" file:
|
|
"""
|
|
Feature: undefined steps
|
|
|
|
Scenario: get version number from api
|
|
When I send "GET" request to "/version" with:
|
|
| col1 | val1 |
|
|
| col2 | val2 |
|
|
Then the response code should be 200 and header "X-Powered-By" should be "godog"
|
|
And the response body should be:
|
|
\"\"\"
|
|
Hello World
|
|
\"\"\"
|
|
"""
|
|
When I run feature suite
|
|
Then the undefined step snippets should be:
|
|
"""
|
|
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
|
// ---
|
|
|
|
|
|
func iSendRequestToWith(arg1, arg2 string, arg3 *godog.Table) { }
|
|
func theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) { }
|
|
func theResponseBodyShouldBe(arg1 *godog.DocString) { }
|
|
|
|
ctx.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith)
|
|
ctx.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe)
|
|
ctx.Step(`^the response body should be:$`, theResponseBodyShouldBe)
|
|
"""
|
|
|
|
Scenario: should handle escaped symbols
|
|
Given a feature "undefined.feature" file:
|
|
"""
|
|
Feature: undefined steps
|
|
|
|
Scenario: get version number from api
|
|
When I pull from github.com
|
|
Then the project should be there
|
|
"""
|
|
When I run feature suite
|
|
Then the following steps should be undefined:
|
|
"""
|
|
I pull from github.com
|
|
the project should be there
|
|
"""
|
|
And the undefined step snippets should be:
|
|
"""
|
|
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
|
// ---
|
|
|
|
|
|
func iPullFromGithubcom() { }
|
|
func theProjectShouldBeThere() { }
|
|
|
|
ctx.Step(`^I pull from github\.com$`, iPullFromGithubcom)
|
|
ctx.Step(`^the project should be there$`, theProjectShouldBeThere)
|
|
"""
|
|
|
|
Scenario: should handle string argument followed by comma
|
|
Given a feature "undefined.feature" file:
|
|
"""
|
|
Feature: undefined
|
|
|
|
Scenario: add item to basket
|
|
Given there is a "Sith Lord Lightsaber", which costs £5
|
|
When I add the "Sith Lord Lightsaber" to the basket
|
|
"""
|
|
When I run feature suite
|
|
And the undefined step snippets should be:
|
|
"""
|
|
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
|
// ---
|
|
|
|
|
|
func thereIsAWhichCosts(arg1 string, arg2 int) { }
|
|
func iAddTheToTheBasket(arg1 string) { }
|
|
|
|
ctx.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
|
|
ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
|
|
"""
|
|
|
|
Scenario: should handle arguments in the beggining or end of the step
|
|
Given a feature "undefined.feature" file:
|
|
"""
|
|
Feature: undefined
|
|
|
|
Scenario: add item to basket
|
|
Given "Sith Lord Lightsaber", which costs £5
|
|
And 12 godogs
|
|
"""
|
|
When I run feature suite
|
|
And the undefined step snippets should be:
|
|
"""
|
|
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
|
// ---
|
|
|
|
|
|
func whichCosts(arg1 string, arg2 int) { }
|
|
func godogs(arg1 int) { }
|
|
|
|
ctx.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts)
|
|
ctx.Step(`^(\d+) godogs$`, godogs)
|
|
"""
|
|
|
|
Scenario: should generate snippets in russian
|
|
and gen'ed functions are in declaration order
|
|
Given a feature "undefined.feature" file:
|
|
"""
|
|
# language: ru
|
|
|
|
Функционал: суперфича
|
|
|
|
Сценарий: делает что-то полезное
|
|
Дано что-то
|
|
Когда я делаю ещё что-то "<param1>", 1, 2, param="<param2>", "<параметр3>", "just string", "<data>"
|
|
То получается ещё более что-то
|
|
Примеры:
|
|
|param1|param2|параметр3|data|
|
|
|--- |--- |--- |--- |
|
|
"""
|
|
When I run feature suite
|
|
Then the following steps should be undefined:
|
|
"""
|
|
получается ещё более что-то
|
|
что-то
|
|
"""
|
|
And the undefined step snippets should be:
|
|
"""
|
|
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
|
// ---
|
|
|
|
|
|
func чтото() { }
|
|
func яДелаюЕщёЧтотоParam(param1 string, arg1, arg2 int, param2, параметр3, arg3, data string) { }
|
|
func получаетсяЕщёБолееЧтото() { }
|
|
|
|
ctx.Step(`^что-то$`, чтото)
|
|
ctx.Step(`^я делаю ещё что-то "([^"]*)", (\d+), (\d+), param="([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$`, яДелаюЕщёЧтотоParam)
|
|
ctx.Step(`^получается ещё более что-то$`, получаетсяЕщёБолееЧтото)
|
|
"""
|