-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bartłomiej Klimczak
authored
Jun 1, 2020
1 parent
cd7c600
commit b30291a
Showing
5 changed files
with
124 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
layout: default | ||
title: Parameter types | ||
--- | ||
|
||
# Parameter types | ||
|
||
GoBDD has support for [parameter types](https://cucumber.io/docs/cucumber/cucumber-expressions/). There are a few predefined parameter types: | ||
|
||
* `{int}` - integer (-1 or 56) | ||
* `{float}` - float (0.4 or 234.4) | ||
* `{word}` - single word (`hello` or `pizza`) | ||
* `{text}` - single-quoted or double-quoted strings (`'I like pizza'` or `"I like pizza"`) | ||
|
||
You can add your own parameter types using `AddParameterTypes()` function. Here are a few examples | ||
|
||
```go | ||
s := gobdd.NewSuite(t) | ||
s.AddParameterTypes(`{int}`, []string{`(\d)`}) | ||
s.AddParameterTypes(`{float}`, []string{`([-+]?\d*\.?\d*)`}) | ||
s.AddParameterTypes(`{word}`, []string{`([\d\w]+)`}) | ||
s.AddParameterTypes(`{text}`, []string{`"([\d\w\-\s]+)"`, `'([\d\w\-\s]+)'`}) | ||
``` | ||
|
||
The first argument accepts the parameter types. As the second parameter provides list of regular expressions that should replace the parameter. | ||
|
||
Parameter types should be added Before adding any step. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Feature: parameter types | ||
Scenario: add two digits | ||
When I add 1 and 2 | ||
Then the result should equal 3 | ||
Scenario: simple word | ||
When I use word pizza | ||
Scenario: simple text with double quotes | ||
When I use text "I like pizza" | ||
Scenario: simple text with single quotes | ||
When I use text 'I like pizza' | ||
Scenario: add two floats | ||
When I add floats 1 and 2 | ||
Then the result should equal float 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters