Cacik executes cucumber scenario with Go functions. Cacik parses go function comments stating with @cacik
to find step
definitions.
Create your feature file and steps in a directory.
├── apple.feature
└── steps.go
apple.feature
Feature: My first feature
Scenario: My first scenario
When I get 3 apples
steps.go
package main
import (
"context"
"fmt"
)
// IGetApples
// @cacik `^I have \d apples$`
func IGetApples(ctx context.Context, appleCount int) (context.Context, error) {
fmt.Printf("I have %d apples", appleCount)
return ctx, nil
}
go install github.com/denizgursoy/cacik/cmd/cacik@latest
cacik
Cacik will create main file
├── apple.feature
├── main.go
└── steps.go
main.go
package main
import (
runner "github.com/denizgursoy/cacik/pkg/runner"
"log"
)
func main() {
err := runner.NewCucumberRunner().
RegisterStep("^I have \\d apples$", IGetApples).
RunWithTags()
if err != nil {
log.Fatal(err)
}
}
To execute scenarios in the feature file, execute:
go run .
It will print I have 3 apples