Skip to content

Latest commit

 

History

History
94 lines (65 loc) · 1.23 KB

README.md

File metadata and controls

94 lines (65 loc) · 1.23 KB

cacik

Cacik executes cucumber scenario with Go functions. Cacik parses go function comments stating with @cacik to find step definitions.

Create files

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
}

Install

go install github.com/denizgursoy/cacik/cmd/cacik@latest

Execute cacik to crate main.go

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)
	}
}

Execute main.go

To execute scenarios in the feature file, execute:

go run .

It will print I have 3 apples