Сравнить коммиты
15 коммитов
Автор | SHA1 | Дата | |
---|---|---|---|
![]() |
be71a25341 | ||
![]() |
ffcc5b10ae | ||
![]() |
eff1e7e3c6 | ||
![]() |
4965079a86 | ||
![]() |
8a7f61cb68 | ||
![]() |
c3ddda4638 | ||
![]() |
9f9f9453dc | ||
![]() |
93631bcb0a | ||
![]() |
2e4e7e9a27 | ||
![]() |
279f4f6aba | ||
![]() |
b2bfe907c6 | ||
![]() |
1a7826f87f | ||
![]() |
4fecb1bba8 | ||
![]() |
5aa8dc6ace | ||
![]() |
99112e7070 |
75 изменённых файлов: 721 добавлений и 235 удалений
140
Magefile.go
Обычный файл
140
Magefile.go
Обычный файл
|
@ -0,0 +1,140 @@
|
|||
//go:build mage
|
||||
// +build mage
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
// mage:import
|
||||
. "magefile/docker"
|
||||
)
|
||||
|
||||
var (
|
||||
GolangVolume = "/gopath/go/1.17"
|
||||
)
|
||||
|
||||
func init() {
|
||||
AppName = "godog"
|
||||
ImageName = "my/go"
|
||||
}
|
||||
|
||||
func Test() {
|
||||
TestNative()
|
||||
TestMakefile()
|
||||
}
|
||||
|
||||
func TestMakefile() {
|
||||
Bash(`sudo docker run -ti --rm \
|
||||
-h host \
|
||||
--net=bridge \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ` + GolangVolume + `:/usr/local/go:ro \
|
||||
\
|
||||
-v /gopath:/gopath:rw \
|
||||
-v ${PWD}:/app \
|
||||
\
|
||||
-e GOPATH=/gopath \
|
||||
-e GOCACHE=/gopath/gocache \
|
||||
\
|
||||
-w /app \
|
||||
-u 1000 \
|
||||
\
|
||||
--entrypoint=/bin/bash \
|
||||
\
|
||||
` + ImageName + " -c '" + `set -x; \
|
||||
make test \
|
||||
'`)
|
||||
}
|
||||
|
||||
func TestNative() {
|
||||
Bash(`sudo docker run -ti --rm \
|
||||
-h host \
|
||||
--net=bridge \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ` + GolangVolume + `:/usr/local/go:ro \
|
||||
\
|
||||
-v /gopath:/gopath:rw \
|
||||
-v ${PWD}:/app \
|
||||
\
|
||||
-e GOPATH=/gopath \
|
||||
-e GOCACHE=/gopath/gocache \
|
||||
\
|
||||
-w /app \
|
||||
-u 1000 \
|
||||
\
|
||||
--entrypoint=/bin/bash \
|
||||
\
|
||||
` + ImageName + " -c '" + `\
|
||||
go test \
|
||||
'`)
|
||||
}
|
||||
|
||||
func TestSnippets() {
|
||||
Bash(`sudo docker run -ti --rm \
|
||||
-h host \
|
||||
--net=bridge \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ` + GolangVolume + `:/usr/local/go:ro \
|
||||
\
|
||||
-v /gopath:/gopath:rw \
|
||||
-v ${PWD}:/app \
|
||||
\
|
||||
-e GOPATH=/gopath \
|
||||
-e GOCACHE=/gopath/gocache \
|
||||
\
|
||||
-w /app \
|
||||
-u 1000 \
|
||||
\
|
||||
--entrypoint=/bin/bash \
|
||||
\
|
||||
` + ImageName + " -c '" + `set -x; \
|
||||
godog run -f progress -c 4 \
|
||||
features/snippets.feature \
|
||||
'`)
|
||||
}
|
||||
|
||||
func TestTags() {
|
||||
Bash(`sudo docker run -ti --rm \
|
||||
-h host \
|
||||
--net=bridge \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ` + GolangVolume + `:/usr/local/go:ro \
|
||||
\
|
||||
-v /gopath:/gopath:rw \
|
||||
-v ${PWD}:/app \
|
||||
\
|
||||
-e GOPATH=/gopath \
|
||||
-e GOCACHE=/gopath/gocache \
|
||||
\
|
||||
-w /app \
|
||||
-u 1000 \
|
||||
\
|
||||
--entrypoint=/bin/bash \
|
||||
\
|
||||
` + ImageName + " -c '" + `set -x; \
|
||||
godog run -f progress -c 4 \
|
||||
features/tags.feature \
|
||||
'`)
|
||||
}
|
||||
|
||||
func Install() {
|
||||
Bash(`sudo docker run -ti --rm \
|
||||
-h host \
|
||||
--net=bridge \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ` + GolangVolume + `:/usr/local/go:ro \
|
||||
\
|
||||
-v /gopath:/gopath:rw \
|
||||
-v ${PWD}:/app \
|
||||
\
|
||||
-e GOPATH=/gopath \
|
||||
-e GOCACHE=/gopath/gocache \
|
||||
\
|
||||
-w /app \
|
||||
-u 1000 \
|
||||
\
|
||||
--entrypoint=/bin/bash \
|
||||
\
|
||||
` + ImageName + " -c '" + `set -x; \
|
||||
go install ./cmd/godog \
|
||||
'`)
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
[](https://vshymanskyy.github.io/StandWithUkraine)
|
||||
[](https://github.com/cucumber/godog/actions?query=branch%main+workflow%3Atest)
|
||||
[](https://pkg.go.dev/github.com/cucumber/godog)
|
||||
[](https://codecov.io/gh/cucumber/godog)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
func getVersion(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
type apiFeature struct {
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/colors"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/colors"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
)
|
||||
|
||||
var opts = godog.Options{
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"io"
|
||||
"math"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/colors"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"strings"
|
||||
|
||||
txdb "github.com/DATA-DOG/go-txdb"
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
module github.com/cucumber/godog/_examples
|
||||
module git.golang1.ru/softonik/godog/_examples
|
||||
|
||||
go 1.16
|
||||
|
||||
replace github.com/cucumber/godog => ../
|
||||
replace git.golang1.ru/softonik/godog => ../
|
||||
|
||||
require (
|
||||
github.com/DATA-DOG/go-txdb v0.1.6
|
||||
github.com/cucumber/godog v0.15.0
|
||||
git.golang1.ru/softonik/godog v0.15.0
|
||||
github.com/go-sql-driver/mysql v1.7.1
|
||||
github.com/spf13/pflag v1.0.6
|
||||
github.com/stretchr/testify v1.8.2
|
||||
|
|
|
@ -15,12 +15,12 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/cucumber/godog/_examples/godogs"
|
||||
"git.golang1.ru/softonik/godog/_examples/godogs"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/colors"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
)
|
||||
|
||||
var opts = godog.Options{
|
||||
|
|
|
@ -2,6 +2,6 @@ module incorrect-project-structure
|
|||
|
||||
go 1.13
|
||||
|
||||
require github.com/cucumber/godog v0.15.0
|
||||
require git.golang1.ru/softonik/godog v0.15.0
|
||||
|
||||
replace github.com/cucumber/godog => ../../
|
||||
replace git.golang1.ru/softonik/godog => ../../
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package main
|
||||
|
||||
import "github.com/cucumber/godog"
|
||||
import "git.golang1.ru/softonik/godog"
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"go/build"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/builder"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/builder"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -40,7 +40,7 @@ The test runner can be executed with the same flags as when using godog run.`,
|
|||
|
||||
func buildCmdRunFunc(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println(colors.Yellow("Use of godog CLI is deprecated, please use *testing.T instead."))
|
||||
fmt.Println(colors.Yellow("See https://github.com/cucumber/godog/discussions/478 for details."))
|
||||
fmt.Println(colors.Yellow("See https://git.golang1.ru/softonik/godog/discussions/478 for details."))
|
||||
|
||||
bin, err := filepath.Abs(buildOutput)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/cucumber/godog/internal/flags"
|
||||
"git.golang1.ru/softonik/godog/internal/flags"
|
||||
)
|
||||
|
||||
var version bool
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/builder"
|
||||
"github.com/cucumber/godog/internal/flags"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/builder"
|
||||
"git.golang1.ru/softonik/godog/internal/flags"
|
||||
)
|
||||
|
||||
var opts flags.Options
|
||||
|
@ -44,7 +44,7 @@ buildable go source.`,
|
|||
|
||||
func runCmdRunFunc(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println(colors.Yellow("Use of godog CLI is deprecated, please use *testing.T instead."))
|
||||
fmt.Println(colors.Yellow("See https://github.com/cucumber/godog/discussions/478 for details."))
|
||||
fmt.Println(colors.Yellow("See https://git.golang1.ru/softonik/godog/discussions/478 for details."))
|
||||
|
||||
osArgs := os.Args[1:]
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
// CreateVersionCmd creates the version subcommand.
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cucumber/godog/cmd/godog/internal"
|
||||
"git.golang1.ru/softonik/godog/cmd/godog/internal"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
|
@ -3,7 +3,7 @@ package godog_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
func ExampleTestSuite_Run_subtests() {
|
||||
|
|
|
@ -295,12 +295,10 @@ Feature: pretty formatter
|
|||
|
||||
You can implement step definitions for undefined steps with these snippets:
|
||||
|
||||
func undefinedDocString(arg1 *godog.DocString) error {
|
||||
return godog.ErrPending
|
||||
func undefinedDocString(arg1 *godog.DocString) {
|
||||
}
|
||||
|
||||
func undefinedTable(arg1 *godog.Table) error {
|
||||
return godog.ErrPending
|
||||
func undefinedTable(arg1 *godog.Table) {
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
|
|
|
@ -20,18 +20,17 @@ Feature: undefined step snippets
|
|||
"""
|
||||
And the undefined step snippets should be:
|
||||
"""
|
||||
func iSendRequestTo(arg1, arg2 string) error {
|
||||
return godog.ErrPending
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
// ---
|
||||
|
||||
|
||||
func iSendRequestTo(arg1, arg2 string) {
|
||||
}
|
||||
func theResponseCodeShouldBe(arg1 int) {
|
||||
}
|
||||
|
||||
func theResponseCodeShouldBe(arg1 int) error {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
ctx.Step(`^I send "([^"]*)" request to "([^"]*)"$`, iSendRequestTo)
|
||||
ctx.Step(`^the response code should be (\d+)$`, theResponseCodeShouldBe)
|
||||
}
|
||||
"""
|
||||
|
||||
Scenario: should generate snippets with more arguments
|
||||
|
@ -52,23 +51,20 @@ Feature: undefined step snippets
|
|||
When I run feature suite
|
||||
Then the undefined step snippets should be:
|
||||
"""
|
||||
func iSendRequestToWith(arg1, arg2 string, arg3 *godog.Table) error {
|
||||
return godog.ErrPending
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
// ---
|
||||
|
||||
|
||||
func iSendRequestToWith(arg1, arg2 string, arg3 *godog.Table) {
|
||||
}
|
||||
func theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) {
|
||||
}
|
||||
func theResponseBodyShouldBe(arg1 *godog.DocString) {
|
||||
}
|
||||
|
||||
func theResponseBodyShouldBe(arg1 *godog.DocString) error {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
func theResponseCodeShouldBeAndHeaderShouldBe(arg1 int, arg2, arg3 string) error {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
ctx.Step(`^I send "([^"]*)" request to "([^"]*)" with:$`, iSendRequestToWith)
|
||||
ctx.Step(`^the response body should be:$`, theResponseBodyShouldBe)
|
||||
ctx.Step(`^the response code should be (\d+) and header "([^"]*)" should be "([^"]*)"$`, theResponseCodeShouldBeAndHeaderShouldBe)
|
||||
}
|
||||
ctx.Step(`^the response body should be:$`, theResponseBodyShouldBe)
|
||||
"""
|
||||
|
||||
Scenario: should handle escaped symbols
|
||||
|
@ -88,18 +84,17 @@ Feature: undefined step snippets
|
|||
"""
|
||||
And the undefined step snippets should be:
|
||||
"""
|
||||
func iPullFromGithubcom() error {
|
||||
return godog.ErrPending
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
// ---
|
||||
|
||||
|
||||
func iPullFromGithubcom() {
|
||||
}
|
||||
func theProjectShouldBeThere() {
|
||||
}
|
||||
|
||||
func theProjectShouldBeThere() error {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
ctx.Step(`^I pull from github\.com$`, iPullFromGithubcom)
|
||||
ctx.Step(`^the project should be there$`, theProjectShouldBeThere)
|
||||
}
|
||||
"""
|
||||
|
||||
Scenario: should handle string argument followed by comma
|
||||
|
@ -114,18 +109,17 @@ Feature: undefined step snippets
|
|||
When I run feature suite
|
||||
And the undefined step snippets should be:
|
||||
"""
|
||||
func iAddTheToTheBasket(arg1 string) error {
|
||||
return godog.ErrPending
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
// ---
|
||||
|
||||
|
||||
func thereIsAWhichCosts(arg1 string, arg2 int) {
|
||||
}
|
||||
func iAddTheToTheBasket(arg1 string) {
|
||||
}
|
||||
|
||||
func thereIsAWhichCosts(arg1 string, arg2 int) error {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
|
||||
ctx.Step(`^there is a "([^"]*)", which costs £(\d+)$`, thereIsAWhichCosts)
|
||||
}
|
||||
ctx.Step(`^I add the "([^"]*)" to the basket$`, iAddTheToTheBasket)
|
||||
"""
|
||||
|
||||
Scenario: should handle arguments in the beggining or end of the step
|
||||
|
@ -140,16 +134,55 @@ Feature: undefined step snippets
|
|||
When I run feature suite
|
||||
And the undefined step snippets should be:
|
||||
"""
|
||||
func godogs(arg1 int) error {
|
||||
return godog.ErrPending
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
// ---
|
||||
|
||||
|
||||
func whichCosts(arg1 string, arg2 int) {
|
||||
}
|
||||
func godogs(arg1 int) {
|
||||
}
|
||||
|
||||
func whichCosts(arg1 string, arg2 int) error {
|
||||
return godog.ErrPending
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
ctx.Step(`^(\d+) godogs$`, godogs)
|
||||
ctx.Step(`^"([^"]*)", which costs £(\d+)$`, whichCosts)
|
||||
}
|
||||
ctx.Step(`^(\d+) godogs$`, godogs)
|
||||
"""
|
||||
|
||||
Scenario: should generate snippets in russian
|
||||
and gen'ed functions are in declaration order
|
||||
Given a feature "undefined.feature" file:
|
||||
"""
|
||||
# language: ru
|
||||
|
||||
Функционал: суперфича
|
||||
|
||||
Сценарий: делает что-то полезное
|
||||
Дано что-то
|
||||
Когда я делаю ещё что-то "<param1>", 1, 2, param="<param2>", "<параметр3>", "just string", "<data>"
|
||||
То получается ещё более что-то
|
||||
Примеры:
|
||||
|param1|param2|параметр3|data|
|
||||
|--- |--- |--- |--- |
|
||||
"""
|
||||
When I run feature suite
|
||||
Then the following steps should be undefined:
|
||||
"""
|
||||
получается ещё более что-то
|
||||
что-то
|
||||
"""
|
||||
And the undefined step snippets should be:
|
||||
"""
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
// ---
|
||||
|
||||
|
||||
func чтото() {
|
||||
}
|
||||
func яДелаюЕщёЧтотоParam(param1 string, arg1, arg2 int, param2, параметр3, arg3, data string) {
|
||||
}
|
||||
func получаетсяЕщёБолееЧтото() {
|
||||
}
|
||||
|
||||
ctx.Step(`^что-то$`, чтото)
|
||||
ctx.Step(`^я делаю ещё что-то "([^"]*)", (\d+), (\d+), param="([^"]*)", "([^"]*)", "([^"]*)", "([^"]*)"$`, яДелаюЕщёЧтотоParam)
|
||||
ctx.Step(`^получается ещё более что-то$`, получаетсяЕщёБолееЧтото)
|
||||
"""
|
||||
|
|
|
@ -125,3 +125,75 @@ Feature: tag filters
|
|||
"""
|
||||
a feature path "four"
|
||||
"""
|
||||
|
||||
Scenario: empty filter and scenarios with f-tag - are executed only
|
||||
Given a feature "normal.feature" file:
|
||||
"""
|
||||
Feature: f-tagged
|
||||
|
||||
Scenario: one
|
||||
Given a feature path "one"
|
||||
|
||||
Scenario: two
|
||||
Given a feature path "two"
|
||||
|
||||
@f
|
||||
Scenario: three
|
||||
Given a feature path "three"
|
||||
|
||||
@f
|
||||
Scenario: four
|
||||
Given a feature path "four"
|
||||
"""
|
||||
When I run feature suite with tags ""
|
||||
Then the suite should have passed
|
||||
And I should have 2 scenario registered
|
||||
And the following steps should be passed:
|
||||
"""
|
||||
a feature path "three"
|
||||
a feature path "four"
|
||||
"""
|
||||
|
||||
Scenario: two feature files and scenarios with f-tag - are executed only
|
||||
Given a feature "normal.feature" file:
|
||||
"""
|
||||
Feature: f-tagged
|
||||
|
||||
Scenario: one
|
||||
Given a feature path "one"
|
||||
|
||||
Scenario: two
|
||||
Given a feature path "two"
|
||||
|
||||
@f
|
||||
Scenario: three
|
||||
Given a feature path "three"
|
||||
|
||||
@f
|
||||
Scenario: four
|
||||
Given a feature path "four"
|
||||
"""
|
||||
And a feature "another.feature" file:
|
||||
"""
|
||||
Feature: non-tagged
|
||||
|
||||
Scenario: five
|
||||
Given a feature path "five"
|
||||
|
||||
Scenario: six
|
||||
Given a feature path "six"
|
||||
|
||||
Scenario: seven
|
||||
Given a feature path "seven"
|
||||
|
||||
Scenario: eight
|
||||
Given a feature path "eight"
|
||||
"""
|
||||
When I run feature suite with tags ""
|
||||
Then the suite should have passed
|
||||
And I should have 2 scenario registered
|
||||
And the following steps should be passed:
|
||||
"""
|
||||
a feature path "three"
|
||||
a feature path "four"
|
||||
"""
|
||||
|
|
4
flags.go
4
flags.go
|
@ -8,8 +8,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
// repeats a space n times
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/formatters"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/formatters"
|
||||
)
|
||||
|
||||
func TestFlagsShouldRandomizeAndGenerateSeed(t *testing.T) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/cucumber/godog/internal/flags"
|
||||
"git.golang1.ru/softonik/godog/internal/flags"
|
||||
)
|
||||
|
||||
// Choose randomly assigns a convenient pseudo-random seed value.
|
||||
|
|
|
@ -3,7 +3,7 @@ package godog
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog/internal/flags"
|
||||
"git.golang1.ru/softonik/godog/internal/flags"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
10
fmt.go
10
fmt.go
|
@ -6,11 +6,11 @@ import (
|
|||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/formatters"
|
||||
internal_fmt "github.com/cucumber/godog/internal/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
internal_fmt "git.golang1.ru/softonik/godog/internal/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
)
|
||||
|
||||
// FindFmt searches available formatters registered
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
func Test_FindFmt(t *testing.T) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
func Test_FindFmt(t *testing.T) {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,4 +1,4 @@
|
|||
module github.com/cucumber/godog
|
||||
module git.golang1.ru/softonik/godog
|
||||
|
||||
go 1.16
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
var astContextSrc = `package main
|
||||
|
||||
import (
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
func MyContext(s *godog.Suite) {
|
||||
|
@ -18,7 +18,7 @@ func MyContext(s *godog.Suite) {
|
|||
var astTwoContextSrc = `package lib
|
||||
|
||||
import (
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
func ApiContext(s *godog.Suite) {
|
||||
|
|
|
@ -23,13 +23,13 @@ var (
|
|||
compiler = filepath.Join(tooldir, "compile")
|
||||
linker = filepath.Join(tooldir, "link")
|
||||
gopaths = filepath.SplitList(build.Default.GOPATH)
|
||||
godogImportPath = "github.com/cucumber/godog"
|
||||
godogImportPath = "git.golang1.ru/softonik/godog"
|
||||
|
||||
// godep
|
||||
runnerTemplate = template.Must(template.New("testmain").Parse(`package main
|
||||
|
||||
import (
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
{{if or .TestSuiteContexts .ScenarioContexts}}_test "{{.ImportPath}}"{{end}}
|
||||
{{if or .XTestSuiteContexts .XScenarioContexts}}_xtest "{{.ImportPath}}_test"{{end}}
|
||||
{{if or .XTestSuiteContexts .XScenarioContexts}}"testing/internal/testdeps"{{end}}
|
||||
|
@ -70,7 +70,7 @@ func main() {
|
|||
// temp file for import
|
||||
tempFileTemplate = template.Must(template.New("temp").Parse(`package {{.Name}}
|
||||
|
||||
import "github.com/cucumber/godog"
|
||||
import "git.golang1.ru/softonik/godog"
|
||||
|
||||
var _ = godog.Version
|
||||
`))
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/internal/builder"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
"git.golang1.ru/softonik/godog/internal/builder"
|
||||
)
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
|
@ -51,7 +51,7 @@ var builderTestFile = `package godogs
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
func thereAreGodogs(available int) error {
|
||||
|
@ -91,7 +91,7 @@ var builderXTestFile = `package godogs_test
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
|
||||
"godogs"
|
||||
)
|
||||
|
@ -138,7 +138,7 @@ func main() {
|
|||
|
||||
var emptyBuilderTestFile = `package godogs
|
||||
|
||||
import "github.com/cucumber/godog"
|
||||
import "git.golang1.ru/softonik/godog"
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
`
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/spf13/pflag"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/cucumber/godog/internal/flags"
|
||||
"git.golang1.ru/softonik/godog/internal/flags"
|
||||
)
|
||||
|
||||
func Test_BindFlagsShouldRespectFlagDefaults(t *testing.T) {
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -13,11 +12,11 @@ import (
|
|||
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
// BaseFormatterFunc implements the FormatterFunc for the base formatter.
|
||||
|
@ -174,7 +173,7 @@ func (f *Base) Summary() {
|
|||
if totalSc == 0 {
|
||||
fmt.Fprintln(f.out, "No scenarios")
|
||||
} else {
|
||||
fmt.Fprintf(f.out, "%d scenarios (%s)\n", totalSc, strings.Join(scenarios, ", "))
|
||||
fmt.Fprintf(f.out, "%d scenarios (%s), ", totalSc, strings.Join(scenarios, ", "))
|
||||
}
|
||||
|
||||
if totalSt == 0 {
|
||||
|
@ -216,7 +215,6 @@ func (f *Base) Snippets() string {
|
|||
// build snippets
|
||||
for _, u := range undefinedStepResults {
|
||||
pickleStep := f.Storage.MustGetPickleStep(u.PickleStepID)
|
||||
|
||||
steps := []string{pickleStep.Text}
|
||||
arg := pickleStep.Argument
|
||||
if u.Def != nil {
|
||||
|
@ -238,7 +236,9 @@ func (f *Base) Snippets() string {
|
|||
case i != 0:
|
||||
w = strings.Title(w)
|
||||
case len(w) > 0:
|
||||
w = string(unicode.ToLower(rune(w[0]))) + w[1:]
|
||||
r := []rune(w)
|
||||
// tut
|
||||
w = string(unicode.ToLower(r[0])) + string(r[1:])
|
||||
}
|
||||
words = append(words, w)
|
||||
}
|
||||
|
@ -256,13 +256,16 @@ func (f *Base) Snippets() string {
|
|||
}
|
||||
}
|
||||
if !found {
|
||||
snips = append(snips, undefinedSnippet{Method: name, Expr: expr, argument: arg})
|
||||
snips = append(snips, undefinedSnippet{
|
||||
Method: name,
|
||||
Expr: expr,
|
||||
argument: arg,
|
||||
argument_names: f.get_argument_names(&u, pickleStep),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort.Sort(snippetSortByMethod(snips))
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err := undefinedSnippetsTpl.Execute(&buf, snips); err != nil {
|
||||
panic(err)
|
||||
|
@ -270,3 +273,58 @@ func (f *Base) Snippets() string {
|
|||
// there may be trailing spaces
|
||||
return strings.Replace(buf.String(), " \n", "\n", -1)
|
||||
}
|
||||
|
||||
func (f *Base) get_argument_names(undefResult *models.PickleStepResult, pickleStep *messages.PickleStep) (arg_names map[int]string) {
|
||||
step := f.find_undef_step(undefResult, pickleStep)
|
||||
if step == nil {
|
||||
return
|
||||
}
|
||||
|
||||
arg_names = map[int]string{}
|
||||
|
||||
args := snippetExprAnyParam.FindAllString(step.Text, -1)
|
||||
for i, a := range args {
|
||||
a = strings.TrimSpace(a)
|
||||
|
||||
if len(a) < 5 {
|
||||
continue
|
||||
}
|
||||
|
||||
parts := strings.Split(a, "\"")
|
||||
if len(parts) < 3 {
|
||||
continue
|
||||
}
|
||||
a = parts[1]
|
||||
|
||||
if a[0] != '<' {
|
||||
continue
|
||||
}
|
||||
|
||||
a = a[1 : len(a)-1]
|
||||
|
||||
// fmt.Printf("\ta: %v: %v\n", a, parts)
|
||||
|
||||
arg_names[i] = a
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
func (f *Base) find_undef_step(undefResult *models.PickleStepResult, pickleStep *messages.PickleStep) *messages.Step {
|
||||
pickle := f.Storage.MustGetPickle(undefResult.PickleID)
|
||||
if pickle == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
feat := f.Storage.MustGetFeature(pickle.Uri)
|
||||
if feat == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(pickleStep.AstNodeIds) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
step_id := pickleStep.AstNodeIds[0]
|
||||
|
||||
return feat.FindStep(step_id)
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/internal/flags"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
"git.golang1.ru/softonik/godog/internal/flags"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
)
|
||||
|
||||
type csiState int
|
||||
|
|
|
@ -19,8 +19,8 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package formatters
|
|||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -3,8 +3,8 @@ package formatters
|
|||
import (
|
||||
"io"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
)
|
||||
|
||||
const fmtOutputTestsFeatureDir = "formatter-tests/features"
|
||||
|
@ -24,7 +24,7 @@ var tT *testing.T
|
|||
func Test_FmtOutput(t *testing.T) {
|
||||
tT = t
|
||||
pkg := os.Getenv("GODOG_TESTED_PACKAGE")
|
||||
os.Setenv("GODOG_TESTED_PACKAGE", "github.com/cucumber/godog")
|
||||
os.Setenv("GODOG_TESTED_PACKAGE", "git.golang1.ru/softonik/godog")
|
||||
|
||||
featureFiles, err := listFmtOutputTestsFeatureFiles()
|
||||
require.Nil(t, err)
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -236,7 +236,7 @@ func (f *Pretty) Summary() {
|
|||
|
||||
fmt.Fprintln(f.out, s(f.indent)+red(scenarioDesc)+line(feature.Uri, astScenario.Location))
|
||||
fmt.Fprintln(f.out, s(f.indent*2)+red(stepDesc)+line(feature.Uri, astStep.Location))
|
||||
fmt.Fprintln(f.out, s(f.indent*3)+red("Error: ")+redb(fmt.Sprintf("%+v", fail.Err))+"\n")
|
||||
fmt.Fprint(f.out, s(f.indent*3)+red("Error: ")+redb(fmt.Sprintf("%+v", fail.Err)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
|
|
|
@ -33,4 +33,4 @@
|
|||
{"event":"TestStepStarted","location":"formatter-tests/features/some_scenarios_including_failing.feature:18","timestamp":-6795364578871}
|
||||
{"event":"TestStepFinished","location":"formatter-tests/features/some_scenarios_including_failing.feature:18","timestamp":-6795364578871,"status":"skipped"}
|
||||
{"event":"TestCaseFinished","location":"formatter-tests/features/some_scenarios_including_failing.feature:16","timestamp":-6795364578871,"status":"ambiguous"}
|
||||
{"event":"TestRunFinished","status":"failed","timestamp":-6795364578871,"snippets":"You can implement step definitions for undefined steps with these snippets:\n\nfunc undefined() error {\n\treturn godog.ErrPending\n}\n\nfunc InitializeScenario(ctx *godog.ScenarioContext) {\n\tctx.Step(`^undefined$`, undefined)\n}\n","memory":""}
|
||||
{"event":"TestRunFinished","status":"failed","timestamp":-6795364578871,"snippets":"You can implement step definitions for undefined steps with these snippets:\n\nfunc undefined() {\n}\n\nfunc InitializeScenario(ctx *godog.ScenarioContext) {\n\tctx.Step(`^undefined$`, undefined)\n}\n","memory":""}
|
||||
|
|
|
@ -56,8 +56,7 @@
|
|||
|
||||
<yellow>You can implement step definitions for undefined steps with these snippets:</yellow>
|
||||
<yellow>
|
||||
func undefined() error {
|
||||
return godog.ErrPending
|
||||
func undefined() {
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
|
|
|
@ -36,8 +36,7 @@
|
|||
|
||||
<yellow>You can implement step definitions for undefined steps with these snippets:</yellow>
|
||||
<yellow>
|
||||
func undefined() error {
|
||||
return godog.ErrPending
|
||||
func undefined() {
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
<yellow>You can implement step definitions for undefined steps with these snippets:</yellow>
|
||||
<yellow>
|
||||
func undefined() error {
|
||||
return godog.ErrPending
|
||||
func undefined() {
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
|
|
|
@ -13,7 +13,8 @@ import (
|
|||
// some snippet formatting regexps
|
||||
var snippetExprCleanup = regexp.MustCompile(`([\/\[\]\(\)\\^\$\.\|\?\*\+\'])`)
|
||||
var snippetExprQuoted = regexp.MustCompile(`(\W|^)"(?:[^"]*)"(\W|$)`)
|
||||
var snippetMethodName = regexp.MustCompile(`[^a-zA-Z\_\ ]`)
|
||||
var snippetExprAnyParam = regexp.MustCompile("(\\W|^)((\\d+)|\"(?:[^\"]*)\")(\\W|$)")
|
||||
var snippetMethodName = regexp.MustCompile("[^a-zA-Zа-яА-ЯёЁ\\_\\ ]")
|
||||
var snippetNumbers = regexp.MustCompile(`(\d+)`)
|
||||
|
||||
var snippetHelperFuncs = template.FuncMap{
|
||||
|
@ -23,19 +24,21 @@ var snippetHelperFuncs = template.FuncMap{
|
|||
}
|
||||
|
||||
var undefinedSnippetsTpl = template.Must(template.New("snippets").Funcs(snippetHelperFuncs).Parse(`
|
||||
{{ range . }}func {{ .Method }}({{ .Args }}) error {
|
||||
return godog.ErrPending
|
||||
}
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {}
|
||||
// ---
|
||||
|
||||
{{end}}func InitializeScenario(ctx *godog.ScenarioContext) { {{ range . }}
|
||||
ctx.Step({{ backticked .Expr }}, {{ .Method }}){{end}}
|
||||
|
||||
{{ range . }}func {{ .Method }}({{ .Args }}) {
|
||||
}
|
||||
{{end}}{{ range . }}
|
||||
ctx.Step({{ backticked .Expr }}, {{ .Method }}){{end}}
|
||||
`))
|
||||
|
||||
type undefinedSnippet struct {
|
||||
Method string
|
||||
Expr string
|
||||
argument *messages.PickleStepArgument
|
||||
argument_names map[int]string
|
||||
}
|
||||
|
||||
func (s undefinedSnippet) Args() (ret string) {
|
||||
|
@ -80,11 +83,25 @@ func (s undefinedSnippet) Args() (ret string) {
|
|||
|
||||
var last string
|
||||
|
||||
// fmt.Printf(" \tArgs: names: %v\n", s.argument_names)
|
||||
|
||||
arg_ind := 0
|
||||
for i, arg := range args {
|
||||
name, ok := s.argument_names[i]
|
||||
if last == "" || last == arg {
|
||||
ret += fmt.Sprintf("arg%d, ", i+1)
|
||||
if ok {
|
||||
ret += fmt.Sprintf("%v, ", name)
|
||||
} else {
|
||||
ret = strings.TrimRight(ret, ", ") + fmt.Sprintf(" %s, arg%d, ", last, i+1)
|
||||
arg_ind++
|
||||
ret += fmt.Sprintf("arg%d, ", arg_ind)
|
||||
}
|
||||
} else {
|
||||
if ok {
|
||||
ret = strings.TrimRight(ret, ", ") + fmt.Sprintf(" %s, %v, ", last, name)
|
||||
} else {
|
||||
arg_ind++
|
||||
ret = strings.TrimRight(ret, ", ") + fmt.Sprintf(" %s, arg%d, ", last, arg_ind)
|
||||
}
|
||||
}
|
||||
|
||||
last = arg
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
// this zeroes the time throughout whole test suite
|
||||
|
|
|
@ -3,8 +3,8 @@ package models_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/testutils"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/testutils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ package models
|
|||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
// TestRunStarted ...
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
)
|
||||
|
||||
type stepResultStatusTestCase struct {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
)
|
||||
|
||||
var typeOfBytes = reflect.TypeOf([]byte(nil))
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ import (
|
|||
gherkin "github.com/cucumber/gherkin/go/v26"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
|
||||
"github.com/cucumber/godog/internal/flags"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/tags"
|
||||
"git.golang1.ru/softonik/godog/internal/flags"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/tags"
|
||||
)
|
||||
|
||||
var pathLineRe = regexp.MustCompile(`:([\d]+)$`)
|
||||
|
@ -186,7 +186,7 @@ func ParseFeatures(fsys fs.FS, filter, dialect string, paths []string) ([]*model
|
|||
features[idx] = feature
|
||||
}
|
||||
|
||||
features = filterFeatures(filter, features)
|
||||
features = FilterFeatures(filter, features)
|
||||
|
||||
return features, nil
|
||||
}
|
||||
|
@ -225,19 +225,61 @@ func ParseFromBytes(filter, dialect string, featuresInputs []FeatureContent) ([]
|
|||
features[idx] = feature
|
||||
}
|
||||
|
||||
features = filterFeatures(filter, features)
|
||||
features = FilterFeatures(filter, features)
|
||||
|
||||
return features, nil
|
||||
}
|
||||
|
||||
func filterFeatures(filter string, features []*models.Feature) (result []*models.Feature) {
|
||||
func FilterFeatures(filter string, features []*models.Feature) (result []*models.Feature) {
|
||||
focused := false
|
||||
|
||||
for _, ft := range features {
|
||||
ft.Pickles = tags.ApplyTagFilter(filter, ft.Pickles)
|
||||
|
||||
if containsFocusedPickle(ft.Pickles) {
|
||||
focused = true
|
||||
}
|
||||
|
||||
if ft.Feature != nil && len(ft.Pickles) > 0 {
|
||||
result = append(result, ft)
|
||||
}
|
||||
}
|
||||
|
||||
if !focused {
|
||||
return
|
||||
}
|
||||
|
||||
var resultF []*models.Feature
|
||||
for _, ft := range result {
|
||||
ft.Pickles = filterFocusedPickles(ft.Pickles)
|
||||
resultF = append(resultF, ft)
|
||||
}
|
||||
|
||||
return resultF
|
||||
}
|
||||
|
||||
func containsFocusedPickle(pickles []*messages.Pickle) bool {
|
||||
for _, p := range pickles {
|
||||
if containsFocusedTag(p.Tags) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
func containsFocusedTag(tags []*messages.PickleTag) bool {
|
||||
for _, t := range tags {
|
||||
if t.Name == "@f" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func filterFocusedPickles(pickles []*messages.Pickle) (result []*messages.Pickle) {
|
||||
for _, p := range pickles {
|
||||
if containsFocusedTag(p.Tags) {
|
||||
result = append(result, p)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog/internal/parser"
|
||||
"git.golang1.ru/softonik/godog/internal/parser"
|
||||
"github.com/cucumber/messages-go/v16"
|
||||
)
|
||||
|
||||
func Test_FeatureFilePathParser(t *testing.T) {
|
||||
|
@ -307,3 +308,54 @@ Funksie: dummy
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_FilterF_Features_FromMultipleFiles(t *testing.T) {
|
||||
const featureFileName = "godogs.feature"
|
||||
const featureFileContentsF = `Feature: focused
|
||||
|
||||
@f
|
||||
Scenario: Focused
|
||||
Given something
|
||||
When do
|
||||
Then ok`
|
||||
|
||||
const featureFileContentsNormal = `Feature: normal
|
||||
Scenario: normal
|
||||
Given something
|
||||
When do
|
||||
Then ok`
|
||||
|
||||
baseDir := filepath.Join(os.TempDir(), t.Name(), "godogs")
|
||||
errA := os.MkdirAll(baseDir+"/a", 0755)
|
||||
errB := os.MkdirAll(baseDir+"/b", 0755)
|
||||
defer os.RemoveAll(baseDir)
|
||||
|
||||
require.Nil(t, errA)
|
||||
require.Nil(t, errB)
|
||||
|
||||
err := ioutil.WriteFile(filepath.Join(baseDir+"/a", featureFileName), []byte(featureFileContentsF), 0644)
|
||||
require.Nil(t, err)
|
||||
err = ioutil.WriteFile(filepath.Join(baseDir+"/b", featureFileName), []byte(featureFileContentsNormal), 0644)
|
||||
require.Nil(t, err)
|
||||
|
||||
features, err := parser.ParseFeatures("", []string{baseDir + "/a", baseDir + "/b"})
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, features, 2)
|
||||
|
||||
for _, f := range features {
|
||||
for _, p := range f.Pickles {
|
||||
if !containsFocusedTag(p.Tags) {
|
||||
assert.Failf(t, "found not Focused pickle", "Found not Focused pickle", p.Tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func containsFocusedTag(tags []*messages.PickleTag) bool {
|
||||
for _, t := range tags {
|
||||
if t.Name == "@f" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"testing"
|
||||
"testing/fstest"
|
||||
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
|
|
@ -2,12 +2,14 @@ package storage
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
"github.com/hashicorp/go-memdb"
|
||||
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -230,6 +232,8 @@ func (s *Storage) MustGetPickleStepResultsByPickleID(pickleID string) (psrs []mo
|
|||
psrs = append(psrs, v.(models.PickleStepResult))
|
||||
}
|
||||
|
||||
sort.Sort(stepsSortByPickleStepID(psrs))
|
||||
|
||||
return psrs
|
||||
}
|
||||
|
||||
|
@ -255,9 +259,33 @@ func (s *Storage) MustGetPickleStepResultsByStatus(status models.StepResultStatu
|
|||
psrs = append(psrs, v.(models.PickleStepResult))
|
||||
}
|
||||
|
||||
sort.Sort(stepsSortByPickleStepID(psrs))
|
||||
|
||||
return psrs
|
||||
}
|
||||
|
||||
type stepsSortByPickleStepID []models.PickleStepResult
|
||||
|
||||
func (s stepsSortByPickleStepID) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s stepsSortByPickleStepID) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
func (s stepsSortByPickleStepID) Less(i, j int) bool {
|
||||
num1, err := strconv.Atoi(s[i].PickleStepID)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
num2, err := strconv.Atoi(s[j].PickleStepID)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return num1 < num2
|
||||
}
|
||||
|
||||
// MustInsertFeature will insert a feature and panic on error.
|
||||
func (s *Storage) MustInsertFeature(f *models.Feature) {
|
||||
s.mustInsert(tableFeature, f)
|
||||
|
|
|
@ -7,9 +7,9 @@ import (
|
|||
messages "github.com/cucumber/messages/go/v21"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"github.com/cucumber/godog/internal/testutils"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/internal/testutils"
|
||||
)
|
||||
|
||||
func Test_MustGetPickle(t *testing.T) {
|
||||
|
|
|
@ -10,6 +10,11 @@ import (
|
|||
// array of pickles and returned the filtered list.
|
||||
func ApplyTagFilter(filter string, pickles []*messages.Pickle) []*messages.Pickle {
|
||||
if filter == "" {
|
||||
ff := filterF(pickles)
|
||||
if len(ff) > 0 {
|
||||
return ff
|
||||
}
|
||||
|
||||
return pickles
|
||||
}
|
||||
|
||||
|
@ -60,3 +65,15 @@ func contains(tags []*messages.PickleTag, tag string) bool {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
func filterF(pickles []*messages.Pickle) []*messages.Pickle {
|
||||
var result = []*messages.Pickle{}
|
||||
|
||||
for _, pickle := range pickles {
|
||||
if contains(pickle.Tags, "f") {
|
||||
result = append(result, pickle)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
37
internal/tags/tag_filter_f_test.go
Обычный файл
37
internal/tags/tag_filter_f_test.go
Обычный файл
|
@ -0,0 +1,37 @@
|
|||
package tags_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"git.golang1.ru/softonik/godog/internal/tags"
|
||||
)
|
||||
|
||||
type testcaseF struct {
|
||||
filter string
|
||||
input []*pickle
|
||||
expected []*pickle
|
||||
}
|
||||
|
||||
var testdataNonF = []*pickle{p1n, p2n, p3n}
|
||||
var testdataF = []*pickle{p1n, p2n, p3withF}
|
||||
var p1n = &pickle{Id: "one", Tags: []*tag{}}
|
||||
var p2n = &pickle{Id: "two", Tags: []*tag{{Name: "@wip"}}}
|
||||
var p3n = &pickle{Id: "three", Tags: []*tag{}}
|
||||
var p3withF = &pickle{Id: "three", Tags: []*tag{{Name: "@f"}}}
|
||||
|
||||
var testcasesF = []testcaseF{
|
||||
{filter: "", input: testdataNonF, expected: testdataNonF},
|
||||
{filter: "", input: testdataF, expected: []*pickle{p3withF}},
|
||||
{filter: "@wip", input: testdataF, expected: []*pickle{p2n}},
|
||||
}
|
||||
|
||||
func Test_ApplyTagFilterWithF(t *testing.T) {
|
||||
for _, tc := range testcasesF {
|
||||
t.Run("", func(t *testing.T) {
|
||||
actual := tags.ApplyTagFilter(tc.filter, tc.input)
|
||||
assert.Equal(t, tc.expected, actual)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/cucumber/godog/internal/tags"
|
||||
"git.golang1.ru/softonik/godog/internal/tags"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
messages "github.com/cucumber/messages/go/v21"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
)
|
||||
|
||||
// BuildTestFeature creates a feature for testing purpose.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package godog
|
||||
|
||||
import "github.com/cucumber/godog/internal/flags"
|
||||
import "git.golang1.ru/softonik/godog/internal/flags"
|
||||
|
||||
// Options are suite run options
|
||||
// flags are mapped to these options.
|
||||
|
|
14
run.go
14
run.go
|
@ -18,13 +18,13 @@ import (
|
|||
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/formatters"
|
||||
ifmt "github.com/cucumber/godog/internal/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/parser"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
ifmt "git.golang1.ru/softonik/godog/internal/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/parser"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
)
|
||||
|
||||
var basicGherkinFeature = `
|
||||
|
@ -134,16 +134,13 @@ func Test_ProgressFormatterMultistepTemplates(t *testing.T) {
|
|||
|
||||
You can implement step definitions for undefined steps with these snippets:
|
||||
|
||||
func three() error {
|
||||
return godog.ErrPending
|
||||
func three() {
|
||||
}
|
||||
|
||||
func unavailableCost(arg1 string, arg2 int) error {
|
||||
return godog.ErrPending
|
||||
func unavailableCost(arg1 string, arg2 int) {
|
||||
}
|
||||
|
||||
func undef() error {
|
||||
return godog.ErrPending
|
||||
func undef() {
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
|
|
|
@ -20,10 +20,10 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
)
|
||||
|
||||
func okStep() error {
|
||||
|
|
8
suite.go
8
suite.go
|
@ -10,10 +10,10 @@ import (
|
|||
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -19,13 +19,12 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cucumber/godog/colors"
|
||||
"github.com/cucumber/godog/internal/formatters"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"github.com/cucumber/godog/internal/parser"
|
||||
"github.com/cucumber/godog/internal/storage"
|
||||
"github.com/cucumber/godog/internal/tags"
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/colors"
|
||||
"git.golang1.ru/softonik/godog/internal/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/internal/parser"
|
||||
"git.golang1.ru/softonik/godog/internal/storage"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
// InitializeScenario provides steps for godog suite execution and
|
||||
|
@ -271,13 +270,13 @@ func (tc *godogFeaturesScenario) iRunFeatureSuiteWithFormatter(name string) erro
|
|||
}
|
||||
|
||||
func (tc *godogFeaturesScenario) iRunFeatureSuiteWithTagsAndFormatter(filter string, fmtFunc FormatterFunc) error {
|
||||
// Entry point for tested feature
|
||||
|
||||
if err := tc.parseFeatures(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, feat := range tc.features {
|
||||
feat.Pickles = tags.ApplyTagFilter(filter, feat.Pickles)
|
||||
}
|
||||
tc.features = parser.FilterFeatures(filter, tc.features)
|
||||
|
||||
tc.testedSuite.storage = storage.NewStorage()
|
||||
for _, feat := range tc.features {
|
||||
|
@ -845,7 +844,7 @@ func (tc *godogFeaturesScenario) theRenderOutputWillBe(docstring *DocString) err
|
|||
actualSuiteCtxReg := regexp.MustCompile(`(suite_context_test\.go|\<autogenerated\>):\d+`)
|
||||
|
||||
expectedSuiteCtxFuncReg := regexp.MustCompile(`SuiteContext.func(\d+)`)
|
||||
actualSuiteCtxFuncReg := regexp.MustCompile(`github.com/cucumber/godog.InitializeScenario.func(\d+)`)
|
||||
actualSuiteCtxFuncReg := regexp.MustCompile(`git.golang1.ru/softonik/godog.InitializeScenario.func(\d+)`)
|
||||
|
||||
suiteCtxPtrReg := regexp.MustCompile(`\*suiteContext`)
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"reflect"
|
||||
"regexp"
|
||||
|
||||
"github.com/cucumber/godog/formatters"
|
||||
"github.com/cucumber/godog/internal/builder"
|
||||
"github.com/cucumber/godog/internal/flags"
|
||||
"github.com/cucumber/godog/internal/models"
|
||||
"git.golang1.ru/softonik/godog/formatters"
|
||||
"git.golang1.ru/softonik/godog/internal/builder"
|
||||
"git.golang1.ru/softonik/godog/internal/flags"
|
||||
"git.golang1.ru/softonik/godog/internal/models"
|
||||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cucumber/godog/internal/utils"
|
||||
"git.golang1.ru/softonik/godog/internal/utils"
|
||||
)
|
||||
|
||||
// this zeroes the time throughout whole test suite
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче