forked from cucumber/gherkin-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpickles_test.go
37 lines (29 loc) · 818 Bytes
/
pickles_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package gherkin
import (
"encoding/json"
"fmt"
"github.com/cucumber/common/messages/go/v19"
"os"
"strings"
)
func ExampleCompilePickles() {
input := `Feature: test
Scenario: test
Given a <color> ball
Examples:
| color |
| red |
`
r := strings.NewReader(input)
gherkinDocument, err := ParseGherkinDocument(r, (&messages.Incrementing{}).NewId)
if err != nil {
fmt.Fprintf(os.Stdout, "%s\n", err)
return
}
pickles := Pickles(*gherkinDocument, "test.feature", (&messages.Incrementing{}).NewId)
marshal, err := json.Marshal(pickles)
fmt.Fprintf(os.Stdout, string(marshal))
// Output:
//
// [{"id":"1","uri":"test.feature","name":"test","language":"en","steps":[{"astNodeIds":["0","2"],"id":"0","type":"Context","text":"a red ball"}],"tags":[],"astNodeIds":["4","2"]}]
}