gherkin

package
v0.0.0-...-7d5c79e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2018 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// The language code for English translations.
	LANG_EN = Language("en")
)

Variables

View Source
var (
	// Translations contains internationalized translations of the Gherkin
	// syntax keywords in a variety of supported languages.
	Translations = map[Language]Translation{
		LANG_EN: Translation{
			Feature:    "Feature",
			Background: "Background",
			Scenario:   "Scenario",
			Outline:    "Scenario Outline",
			And:        "And",
			Given:      "Given",
			When:       "When",
			Then:       "Then",
			Examples:   "Examples",
		},
	}
)

Functions

This section is empty.

Types

type Feature

type Feature struct {
	// The filename where the feature was defined
	Filename string

	// The line number where the feature was defined
	Line int

	// The feature's title.
	Title string

	// A longer description of the feature. This is not used during runtime.
	Description string

	// Any tags associated with this feature.
	Tags []string

	// Any background scenario data that is executed prior to scenarios.
	Background Scenario

	// The scenarios associated with this feature.
	Scenarios []Scenario
	// contains filtered or unexported fields
}

Feature represents the top-most construct in a Gherkin document. A feature contains one or more scenarios, which in turn contains multiple steps.

func Parse

func Parse(data string) ([]Feature, error)

func ParseFilename

func ParseFilename(data, filename string) ([]Feature, error)

func (*Feature) FilterMatched

func (f *Feature) FilterMatched(filters ...string) bool

FilterMatched returns true if the set of input filters match the feature's tags.

func (*Feature) LongestLine

func (f *Feature) LongestLine() int

LongestLine returns the longest step line in a feature.

type Language

type Language string

type Scenario

type Scenario struct {
	// The filename where the scenario was defined
	Filename string

	// The line number where the scenario was defined
	Line int

	// The scenario's title. For backgrounds, this is the empty string.
	Title string

	// Any tags associated with this scenario.
	Tags []string

	// All steps associated with the scenario.
	Steps []Step

	// Contains all scenario outline example data, if provided.
	Examples StringData
	// contains filtered or unexported fields
}

Scenario represents a scenario (or background) of a given feature.

func (*Scenario) FilterMatched

func (s *Scenario) FilterMatched(f *Feature, filters ...string) bool

FilterMatched returns true if the set of input filters match the feature's tags.

func (*Scenario) LongestLine

func (s *Scenario) LongestLine() int

LongestLine returns the longest step line in a scenario.

type Step

type Step struct {
	// The filename where the step was defined
	Filename string

	// The line number where the step was defined
	Line int

	// The step's "type" (Given, When, Then, And, ...)
	//
	// Note that this field is normalized to the English form (e.g., "Given").
	Type StepType

	// The text contained in the step (minus the "Type" prefix).
	Text string

	// Argument represents multi-line argument data attached to a step.
	Argument StringData
}

Step represents an individual step making up a gucumber scenario.

type StepType

type StepType string

StepType represents a given step type.

type StringData

type StringData string

StringData is multi-line docstring text attached to a step.

func (StringData) IsTabular

func (s StringData) IsTabular() bool

IsTabular returns whether the argument data is a table

func (StringData) ToTable

func (s StringData) ToTable() TabularData

ToTable turns StringData type into a TabularData type

type TabularData

type TabularData [][]string

TabularData is tabular text data attached to a step.

func (TabularData) ToMap

func (t TabularData) ToMap() TabularDataMap

ToMap converts a regular table to a map of header names to their row data. For example:

t := TabularData{[]string{"header1", "header2"}, []string{"col1", "col2"}}
t.ToMap()
// Output:
//   map[string][]string{
//     "header1": []string{"col1"},
//     "header2": []string{"col2"},
//   }

type TabularDataMap

type TabularDataMap map[string][]string

TabularDataMap is tabular text data attached to a step organized in map form of the header name and its associated row data.

func (TabularDataMap) NumRows

func (t TabularDataMap) NumRows() int

NumRows returns the number of rows in a table map

type Translation

type Translation struct {
	// Language specific term representing a feature.
	Feature string

	// Language specific term representing the feature background.
	Background string

	// Language specific term representing a scenario.
	Scenario string

	// Language specific term representing a scenario outline.
	Outline string

	// Language specific term representing the "And" step.
	And string

	// Language specific term representing the "Given" step.
	Given string

	// Language specific term representing the "When" step.
	When string

	// Language specific term representing the "Then" step.
	Then string

	// Language specific term representing a scenario outline prefix.
	Examples string
}

Translation represents the Gherkin syntax keywords in a single language.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL