runner

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package runner provides the test runners that run sets of test cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Jest

type Jest struct {
	RunnerConfig
}

func NewJest

func NewJest(j RunnerConfig) Jest

func (Jest) GetExamples

func (j Jest) GetExamples(files []string) ([]plan.TestCase, error)

func (Jest) GetFiles

func (j Jest) GetFiles() ([]string, error)

GetFiles returns an array of file names using the discovery pattern.

func (Jest) Name

func (j Jest) Name() string

func (Jest) ParseReport

func (j Jest) ParseReport(path string) (JestReport, error)

func (Jest) Run

func (j Jest) Run(testCases []string, retry bool) (RunResult, error)

type JestExample

type JestExample struct {
	Name   string `json:"fullName"`
	Status string `json:"status"`
}

type JestReport

type JestReport struct {
	NumFailedTests int
	TestResults    []struct {
		AssertionResults []JestExample
	}
}

type ProcessSignaledError

type ProcessSignaledError struct {
	Signal syscall.Signal
}

func (*ProcessSignaledError) Error

func (e *ProcessSignaledError) Error() string

type Rspec

type Rspec struct {
	RunnerConfig
}

func NewRspec

func NewRspec(r RunnerConfig) Rspec

func (Rspec) GetExamples

func (r Rspec) GetExamples(files []string) ([]plan.TestCase, error)

GetExamples returns an array of test examples within the given files.

func (Rspec) GetFiles

func (r Rspec) GetFiles() ([]string, error)

GetFiles returns an array of file names using the discovery pattern.

func (Rspec) Name

func (r Rspec) Name() string

func (Rspec) ParseReport

func (r Rspec) ParseReport(path string) (RspecReport, error)

func (Rspec) Run

func (r Rspec) Run(testCases []string, retry bool) (RunResult, error)

Run executes the test command with the given test cases. If retry is true, it will run the command using the retry test command, otherwise it will use the test command.

Error is returned if the command fails to run, exits prematurely, or if the output cannot be parsed.

Test failure is not considered an error, and is instead returned as a RunResult.

type RspecExample

type RspecExample struct {
	Id              string  `json:"id"`
	Description     string  `json:"description"`
	FullDescription string  `json:"full_description"`
	Status          string  `json:"status"`
	FilePath        string  `json:"file_path"`
	LineNumber      int     `json:"line_number"`
	RunTime         float64 `json:"run_time"`
}

RspecExample represents a single test example in an Rspec report.

type RspecReport

type RspecReport struct {
	Version  string         `json:"version"`
	Seed     int            `json:"seed"`
	Examples []RspecExample `json:"examples"`
	Summary  struct {
		ExampleCount int `json:"example_count"`
		FailureCount int `json:"failure_count"`
		PendingCount int `json:"pending_count"`
	}
}

RspecReport is the structure for Rspec JSON report.

type RunResult

type RunResult struct {
	Status      RunStatus
	FailedTests []string
}

type RunStatus

type RunStatus string
const (
	RunStatusPassed RunStatus = "passed"
	RunStatusFailed RunStatus = "failed"
	RunStatusError  RunStatus = "error"
)

type RunnerConfig

type RunnerConfig struct {
	TestRunner             string
	TestCommand            string
	TestFilePattern        string
	TestFileExcludePattern string
	RetryTestCommand       string
	ResultPath             string
}

type TestRunner

type TestRunner interface {
	Run(testCases []string, retry bool) (RunResult, error)
	GetExamples(files []string) ([]plan.TestCase, error)
	GetFiles() ([]string, error)
	Name() string
}

func DetectRunner

func DetectRunner(cfg config.Config) (TestRunner, error)

Jump to

Keyboard shortcuts

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