Help us shape the future of Go! Take the 2026 Go Developer Survey

gi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

gi

gi

Karate for Go. API tests, mocks, and load tests. One binary. No JVM.

Go 1.27.2 CI Apache 2.0 Documentation Go Reference

Documentation · Quick start · Examples

go install github.com/gi-runner/gi/cmd/gi@latest

examples/users.feature against examples/users.mock.feature:

Feature: Users API

Background:
  * url baseUrl
  * header Accept = 'application/json'
  * def email = 'ada-' + uuid() + '@example.com'

Scenario: create a user and read it back
  * path 'users'
  * request { name: 'Ada Lovelace', age: 36, email: '#(email)', tags: ['math', 'poet'] }
  * method post
  * status 201
  * match response contains { id: '#uuid', name: 'Ada Lovelace' }
  * def id = response.id
  * path 'users', id
  * method get
  * status 200
  * match response.id == id
gi mock examples/users.mock.feature --addr :18080

In another terminal:

gi test examples/users.feature --var baseUrl=http://127.0.0.1:18080 --report report.html
gi load examples/users.feature --var baseUrl=http://127.0.0.1:18080 --vus 20 --duration 30s

Documentation

Overview

Package gi runs Karate-style feature files without a JVM.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, fn func([]any) (any, error)) error

Register adds a function to the gi and karate objects for later runs. The function receives the JavaScript arguments. Built-in names are rejected.

func Unregister

func Unregister(name string)

Unregister removes a function added by Register.

Types

type Exchange

type Exchange = engine.Exchange

Exchange records an HTTP request and response with masked sensitive headers.

type FileResult

type FileResult = engine.FileResult

FileResult is the result of one feature file, including its scenarios and steps.

func Run

func Run(ctx context.Context, paths []string, opt Options) ([]FileResult, error)

Run executes the named feature files. Failed assertions are represented in the results; errors report parsing, setup, or cancellation failures. Check Passed on every result, even when err is nil. Directories are not expanded by this API.

type Options

type Options struct {
	Vars    map[string]any
	Env     string
	Tags    string
	Jobs    int
	Timeout time.Duration
	Client  *http.Client
	Output  io.Writer
}

Options configures a functional run. A nil Client uses http.DefaultClient. Each scenario owns its cookie jar; the client's transport can be shared.

type ScenarioResult

type ScenarioResult = engine.ScenarioResult

ScenarioResult describes one executed or skipped scenario.

type StepResult

type StepResult = engine.StepResult

StepResult describes one step, including nested calls and HTTP exchanges.

Directories

Path Synopsis
cmd
gi command
examples
server command
internal
adapters
Package adapters wires the native protocol and browser implementations.
Package adapters wires the native protocol and browser implementations.
cli
engine
HTTP dialing stays behind Sender.
HTTP dialing stays behind Sender.
feature
Step bodies stay as text.
Step bodies stay as text.
match
A missing key is not null.
A missing key is not null.
mock
methodIs, pathMatches, and a failed match skip the scenario instead of failing it.
methodIs, pathMatches, and a failed match skip the scenario instead of failing it.
script
Paths such as response.users[*].id are evaluated in Go.
Paths such as response.users[*].id are evaluated in Go.
value
Package value is the JSON-shaped data model shared by the script runtime and the matcher.
Package value is the JSON-shaped data model shared by the script runtime and the matcher.
wsx
xml

Jump to

Keyboard shortcuts

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