testing

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Case

type Case struct {
	// Name of the testcase
	Name string
	// Values of gloal variables before run
	Inputs map[string]interface{}
	// Expected values of global vars after run
	Outputs map[string]interface{}
	// The same as Script.StopWhen. Both are merged together so this can be used to override/extend the script stop-conditions
	StopWhen map[string]interface{}
}

Case defines inputs and expected outputs for a run

type CaseRunner added in v0.0.19

type CaseRunner struct {
	Coordinator     *vm.Coordinator
	VMs             []*vm.VM
	VarTranslations []map[string]string
	Case            *Case
	StopConditions  map[string]*vm.Variable
}

CaseRunner represents a prepared test-case that is ready to run

func (CaseRunner) Run added in v0.0.19

func (cr CaseRunner) Run() []error

Run executes the case-runner

type Script

type Script struct {
	// The absolut path where the test-file was located. Used to retrieve the script files.
	TestPath string
	// Name of the script to run
	Name string
	// Content is the content of the script. If empty, it is loaded from disk at run-time
	Content string
}

Script contains run-options for a script in the test

func (Script) GetCode

func (script Script) GetCode() (string, error)

GetCode returns the code for script either from the script struct itself or from the referenced file

type Test

type Test struct {
	// The path where the test-file was located. Used to retrieve the script files.
	Path string
	// Scripts to use in this test
	Scripts []Script
	// Cases for this test
	Cases []Case
	// Maximum number of lines to run from the script (0=infinite)
	MaxLines int
	// Stop when is a map from global variable-name to value
	// Execution is stopped when at least one of the listed variables is equal to the value
	StopWhen map[string]interface{}
}

Test defines a test-run

func Parse

func Parse(file []byte, path string) (Test, error)

Parse parses a yaml file into a Test path is the path from where the test was loaded. This is needed as the scripts are located relatice to the test-file

func (Test) GetRunner added in v0.0.19

func (t Test) GetRunner(casenr int) (runner *CaseRunner, err error)

GetRunner creates an executable TestRunner for the given testcase

func (Test) Run

func (t Test) Run(callback func(Case)) []error

Run runs all test-cases

Jump to

Keyboard shortcuts

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