Merge pull request #163 from cbush06/master

Added datatables to cucumber json results files.
Этот коммит содержится в:
Gediminas Morkevicius 2019-03-15 09:14:56 +02:00 коммит произвёл GitHub
родитель c5e4234734 8242348e2a
коммит 0c55e288b6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 27 добавлений и 6 удалений

3
.gitignore предоставленный
Просмотреть файл

@ -1,2 +1,5 @@
/cmd/godog/godog
/example/example
**/vendor/*
Gopkg.lock
Gopkg.toml

Просмотреть файл

@ -71,12 +71,17 @@ type cukeMatch struct {
}
type cukeStep struct {
Keyword string `json:"keyword"`
Name string `json:"name"`
Line int `json:"line"`
Docstring *cukeDocstring `json:"doc_string,omitempty"`
Match cukeMatch `json:"match"`
Result cukeResult `json:"result"`
Keyword string `json:"keyword"`
Name string `json:"name"`
Line int `json:"line"`
Docstring *cukeDocstring `json:"doc_string,omitempty"`
Match cukeMatch `json:"match"`
Result cukeResult `json:"result"`
DataTable []*cukeDataTableRow `json:"rows,omitempty"`
}
type cukeDataTableRow struct {
Cells []string `json:"cells"`
}
type cukeElement struct {
@ -285,6 +290,19 @@ func (f *cukefmt) Defined(step *gherkin.Step, def *StepDef) {
f.curStep.Docstring.Value = step.Argument.(*gherkin.DocString).Content
}
if _, ok := step.Argument.(*gherkin.DataTable); ok {
dataTable := step.Argument.(*gherkin.DataTable)
f.curStep.DataTable = make([]*cukeDataTableRow, len(dataTable.Rows))
for i, row := range dataTable.Rows {
cells := make([]string, len(row.Cells))
for j, cell := range row.Cells {
cells[j] = cell.Value
}
f.curStep.DataTable[i] = &cukeDataTableRow{Cells: cells}
}
}
if def != nil {
f.curStep.Match.Location = strings.Split(def.definitionID(), " ")[0]
}