scenarigo

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

README

scenarigo

godoc test codecov go report codebeat License

An end-to-end scenario testing tool for HTTP/gRPC server.

Overview

scenarigo is an end-to-end scenario testing tool for HTTP/gRPC server. It is written in Go, enable to customize by the plugin package of Go. You can write test scenarios as YAML files and executes them.

title: get scenarigo repository
steps:
- title: GET https://api.github.com/repos/zoncoen/scenarigo
  vars:
    user: zoncoen
    repo: scenarigo
  protocol: http
  request:
    method: GET
    url: "https://api.github.com/repos/{{vars.user}}/{{vars.repo}}"
  expect:
    code: OK
    body:
      name: "{{vars.repo}}"
Use as CLI tool
$ scenarigo run github.yaml
Use as Go package
package main

import (
	"testing"

	"github.com/zoncoen/scenarigo"
	"github.com/zoncoen/scenarigo/context"
)

func TestGitHub(t *testing.T) {
	r, err := scenarigo.NewRunner(
		scenarigo.WithScenarios(
			"testdata/github.yaml",
		),
	)
	if err != nil {
		t.Fatalf("failed to create a test runner: %s", err)
	}
	r.Run(context.FromT(t))
}
$ go test . -run "TestGitHub"

Features

  • provides the command-line tool and the Go package for testing
  • supports HTTP and gRPC
  • customization by writing Go code

Installation

Go to the releases page and download the zip file. Unpack the zip file, and put the binary to a directory in your $PATH.

Usage

scenarigo is a scenario testing tool for APIs.

Usage:
  scenarigo [command]

Available Commands:
  help        Help about any command
  run         run test scenarios
  version     print scenarigo version

Flags:
  -h, --help   help for scenarigo

Use "scenarigo [command] --help" for more information about a command.

Development

This project uses the Makefile as a task runner.

Available commands
test                           run tests
coverage                       measure test coverage
lint                           run lint
gen                            generate necessary files for testing
release                        release new version
changelog                      generate CHANGELOG.md
credits                        generate CREDITS
help                           print help

Documentation

Overview

Package scenarigo provides end-to-end scenario testing framework for APIs. It loads YAML files as scenarios and executes them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithOptionsFromEnv added in v0.3.0

func WithOptionsFromEnv(isEnv bool) func(*Runner) error

WithOptionsFromEnv returns a option which sets flag whether accepts configuration from ENV. Currently Available ENV variables are the following. - SCENARIGO_COLOR=(1|true|TRUE) nolint:stylecheck

func WithPluginDir

func WithPluginDir(path string) func(*Runner) error

WithPluginDir returns a option which sets plugin root directory.

func WithScenarios

func WithScenarios(paths ...string) func(*Runner) error

WithScenarios returns a option which finds and sets test scenario files.

Types

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner represents a test runner.

func NewRunner

func NewRunner(opts ...func(*Runner) error) (*Runner, error)

NewRunner returns a new test runner.

func (*Runner) Run

func (r *Runner) Run(ctx *context.Context)

Run runs all tests.

func (*Runner) ScenarioFiles added in v0.4.0

func (r *Runner) ScenarioFiles() []string

ScenariosFiles returns all scenario file paths.

func (*Runner) ScenarioMap added in v0.4.0

func (r *Runner) ScenarioMap(ctx *context.Context, path string) (map[string][]string, error)

Scenarios returns map for all scenarios ( key is scenario name and value is steps of scenario ).

Directories

Path Synopsis
Package assert provides value assertions.
Package assert provides value assertions.
cmd
Package context provides the test context of scenarigo.
Package context provides the test context of scenarigo.
examples
internal
Package protocol provides defines APIs of protocol.
Package protocol provides defines APIs of protocol.
query
Package reporter provides test result reporters.
Package reporter provides test result reporters.
Package schema provides the test scenario data schema for scenarigo.
Package schema provides the test scenario data schema for scenarigo.
scripts
cross-build Module
Package template implements data-driven templates for generating a value.
Package template implements data-driven templates for generating a value.
ast
Package ast declares the types used to represent syntax trees.
Package ast declares the types used to represent syntax trees.
parser
Package parser implements a parser for a template string.
Package parser implements a parser for a template string.
token
Package token defines constants representing the lexical tokens.
Package token defines constants representing the lexical tokens.

Jump to

Keyboard shortcuts

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