Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Go Package gherkin implements a parser for the Gherkin language, used for Story/Feature based Behavior Driven Development.

License

NotificationsYou must be signed in to change notification settings

muhqu/go-gherkin

Repository files navigation

Build Status

Package gherkin implements a parser for the Gherkin language, used forStory/Feature based Behavior Driven Development.

The parser is generated via@pointlander's awesomepeg parser generator.

Read theDocumentation over atgodoc.org.

Install

Via Go Get

$ go get github.com/muhqu/go-gherkin

Via GNU Make

$ git clone https://github.com/muhqu/go-gherkin...$cd go-gherkin/$ make get-deps buildtest install

Usage Example

import ("github.com/muhqu/go-gherkin")funcmain() {feature,_:=gherkin.ParseGherkinFeature(`@wipFeature: Hello World  The world is a beautiful place  So let people be nice to each other  @nice @people  Scenario: Nice people    Given a nice person called "Bob"      And a nice person called "Lisa"     When "Bob" says to "Lisa": "Hello!"     Then "Lisa" should reply to "Bob": "Hello!"`)fmt.Printf("feature: %#v %#v\n",feature.Title(),feature.Tags())fmt.Printf("no. scenarios: %#v\n",len(feature.Scenarios()))fori,scenario:=rangefeature.Scenarios() {fmt.Printf("scenario %d: %#v %#v\n",i+1,scenario.Title(),scenario.Tags())fori,step:=rangescenario.Steps() {fmt.Printf("  step %d: %#v %#v\n",i+1,step.StepType(),step.Text())        }    }}

Output:

feature: "Hello World" []string{"wip"}no. scenarios: 1scenario 1: "Nice people" []string{"nice", "people"}  step 1: "Given" "a nice person called \"Bob\""  step 2: "And" "a nice person called \"Lisa\""  step 3: "When" "\"Bob\" says to \"Lisa\": \"Hello!\""  step 4: "Then" "\"Lisa\" should reply to \"Bob\": \"Hello!\""

Using Go-Gherkin

Projects using go-gherkin package:

  • gherkinfmt - Commandline tool to format Gherkin files.

Author

© 2014 by Mathias Leppich
github.com/muhqu,@muhqu

About

Go Package gherkin implements a parser for the Gherkin language, used for Story/Feature based Behavior Driven Development.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp