runner

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 16 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 Cypress added in v1.1.0

type Cypress struct {
	RunnerConfig
}

func NewCypress added in v1.1.0

func NewCypress(c RunnerConfig) Cypress

func (Cypress) GetExamples added in v1.1.0

func (c Cypress) GetExamples(files []string) ([]plan.TestCase, error)

func (Cypress) GetFiles added in v1.1.0

func (c Cypress) GetFiles() ([]string, error)

func (Cypress) Name added in v1.1.0

func (c Cypress) Name() string

func (Cypress) Run added in v1.1.0

func (c Cypress) Run(result *RunResult, testCases []plan.TestCase, retry bool) error

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(result *RunResult, testCases []plan.TestCase, retry bool) error

type JestExample

type JestExample struct {
	Name           string   `json:"fullName"`
	Status         string   `json:"status"`
	Title          string   `json:"title"`
	AncestorTitles []string `json:"ancestorTitles"`
}

type JestReport

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

type Playwright added in v1.1.0

type Playwright struct {
	RunnerConfig
}

func NewPlaywright added in v1.1.0

func NewPlaywright(p RunnerConfig) Playwright

func (Playwright) GetExamples added in v1.1.0

func (p Playwright) GetExamples(files []string) ([]plan.TestCase, error)

func (Playwright) GetFiles added in v1.1.0

func (p Playwright) GetFiles() ([]string, error)

func (Playwright) Name added in v1.1.0

func (p Playwright) Name() string

func (Playwright) Run added in v1.1.0

func (p Playwright) Run(result *RunResult, testCases []plan.TestCase, retry bool) error

type PlaywrightReport added in v1.1.0

type PlaywrightReport struct {
	Suites []PlaywrightReportSuite
	Stats  struct {
		Expected   int
		Unexpected int
	}
	Errors []struct {
		Message string
	}
}

type PlaywrightReportSuite added in v1.1.0

type PlaywrightReportSuite struct {
	Title  string
	Specs  []PlaywrightSpec
	Suites []PlaywrightReportSuite
}

type PlaywrightSpec added in v1.1.0

type PlaywrightSpec struct {
	File   string
	Line   int
	Column int
	Id     string
	Title  string
	Ok     bool
	Tests  []PlaywrightTest
}

type PlaywrightTest added in v1.2.0

type PlaywrightTest struct {
	ProjectName string
}

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(result *RunResult, testCases []plan.TestCase, retry bool) 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"`
		ErrorsOutsideOfExamplesCount int `json:"errors_outside_of_examples_count"`
	}
}

RspecReport is the structure for Rspec JSON report.

type RunResult

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

RunResult is a struct to keep track the results of a test run. It contains the logics to record test results, calculate the status of the run.

func NewRunResult added in v1.2.0

func NewRunResult(mutedTests []plan.TestCase) *RunResult

func (*RunResult) Error added in v1.2.1

func (r *RunResult) Error() error

func (*RunResult) FailedTests

func (r *RunResult) FailedTests() []plan.TestCase

FailedTests returns a list of test cases that failed.

func (*RunResult) MutedTests added in v1.2.0

func (r *RunResult) MutedTests() []TestResult

func (*RunResult) RecordTestResult added in v1.2.0

func (r *RunResult) RecordTestResult(testCase plan.TestCase, status TestStatus)

RecordTestResult records the result of a test case. If the test case found in the mutedTestLookup, it will be marked as muted.

func (*RunResult) Statistics added in v1.2.0

func (r *RunResult) Statistics() RunStatistics

func (*RunResult) Status

func (r *RunResult) Status() RunStatus

Status returns the overall status of the test run. If there is an error, it returns RunStatusError. If there are failed tests, it returns RunStatusFailed. Otherwise, it returns RunStatusPassed.

type RunStatistics added in v1.2.0

type RunStatistics struct {
	Total            int
	PassedOnFirstRun int
	PassedOnRetry    int
	MutedPassed      int
	MutedFailed      int
	Failed           int
}

type RunStatus

type RunStatus string
const (
	// RunStatusPassed indicates that the run was completed and all tests passed.
	RunStatusPassed RunStatus = "passed"
	// RunStatusFailed indicates that the run was completed, but one or more tests failed.
	RunStatusFailed RunStatus = "failed"
	// RunStatusError indicates that the run was completed, but there was an error outside of the tests.
	RunStatusError RunStatus = "error"
	// RunStatusUnknown indicates that the run status is unknown.
	// It could be that no tests were run, run was interrupted, or the report is not available.
	RunStatusUnknown RunStatus = "unknown"
)

type RunnerConfig

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

type TestResult added in v1.2.0

type TestResult struct {
	plan.TestCase
	Status         TestStatus
	ExecutionCount int
	Muted          bool
}

TestResult is a struct to keep track the result of an individual test case.

type TestRunner

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

func DetectRunner

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

type TestStatus added in v1.2.0

type TestStatus string
const (
	TestStatusPassed  TestStatus = "passed"
	TestStatusFailed  TestStatus = "failed"
	TestStatusPending TestStatus = "pending"
)

Jump to

Keyboard shortcuts

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