Documentation
¶
Overview ¶
Package testrunner provides test runner functionality.
Index ¶
- Constants
- func GetFunctionsFromFiles(files []string) (map[string]File, error)
- func GetModuleName(path string) string
- func GetOverallCoveragePercentage(output []byte) float64
- func HighlightCode(language string, code string) string
- type CoverageLine
- type File
- type Function
- type Line
- type TestEvent
- type TestResult
- type TestRunner
- func (t *TestRunner) AddOutput(output []string) []string
- func (t *TestRunner) Close()
- func (t *TestRunner) GetCoverage() float64
- func (t *TestRunner) GetFiles() map[string]File
- func (t *TestRunner) GetFuncCoveragePercentages(coverageFile string) (map[string]map[string]float64, float64, error)
- func (t *TestRunner) GetHasRunTests() bool
- func (t *TestRunner) GetIsRunning() bool
- func (t *TestRunner) GetOutput() []string
- func (t *TestRunner) ParseCoverage(coverageFile string) ([]CoverageLine, error)
- func (t *TestRunner) ParseCoverageLines(coverageLines []CoverageLine, ...) []File
- func (t *TestRunner) ParseErrorFromOutput(output string) string
- func (t *TestRunner) RunAllTests(testCompleteCallback func(file File) error, ...)
- func (t *TestRunner) SetCoverage(coverage float64)
- func (t *TestRunner) SetHasRunTests(hasRunTests bool)
- func (t *TestRunner) SetIsRunning(running bool)
- func (t *TestRunner) SetOnFileChange(callback func())
- func (t *TestRunner) StopTests()
- type TestStatus
Constants ¶
const ( // TestStatusPending represents a test that is pending. TestStatusPending = iota // TestStatusRunning represents a test that is running. TestStatusRunning // TestStatusPassed represents a test that has passed. TestStatusPassed // TestStatusFailed represents a test that has failed. TestStatusFailed // TestStatusNoCodeToCover represents a file with no code that can be covered. TestStatusNoCodeToCover )
Variables ¶
This section is empty.
Functions ¶
func GetFunctionsFromFiles ¶
GetFunctionsFromFiles gets all functions from the supplied files.
func GetModuleName ¶
GetModuleName gets the module name of the Go project in the specified path.
func GetOverallCoveragePercentage ¶
GetOverallCoveragePercentage gets the overall coverage percentage.
func HighlightCode ¶
HighlightCode highlights code for a given language.
Types ¶
type CoverageLine ¶
type CoverageLine struct {
File string `json:"file"`
StartLine int `json:"startLine"`
StartColumn int `json:"startColumn"`
EndLine int `json:"endLine"`
EndColumn int `json:"endColumn"`
NumberOfStatements int `json:"numberOfStatements"`
ExecutionCount int `json:"executionCount"`
}
CoverageLine defines a coverage line.
type File ¶
type File struct {
Name string `json:"name"`
Functions []Function `json:"functions"`
Code string `json:"code"`
HighlightedCode string `json:"highlightedCode"`
Status TestStatus `json:"status"`
Coverage float64 `json:"coverage"`
CoveredLines []Line `json:"coveredLines"`
}
File defines a test file.
type Function ¶
type Function struct {
Name string `json:"name"`
Result TestResult `json:"result"`
}
Function defines a single function.
type Line ¶
type Line struct {
Number int `json:"number"`
StartLine int `json:"startLine"`
StartColumn int `json:"startColumn"`
EndLine int `json:"endLine"`
EndColumn int `json:"endColumn"`
ExecutionCount int `json:"executionCount"`
NumberOfStatements int `json:"numberOfStatements"`
}
Line defines a line of code in a coverage report.
type TestEvent ¶
type TestEvent struct {
Time string `json:"time"`
Action string `json:"action"`
Package string `json:"package"`
Test string `json:"test"`
Output string `json:"output"`
Elapsed float64 `json:"elapsed"`
}
TestEvent represents a single test event from Go test output in JSON format.
type TestResult ¶
type TestResult struct {
Coverage float64 `json:"coverage"`
}
TestResult defines the result of a test.
type TestRunner ¶
type TestRunner struct {
// contains filtered or unexported fields
}
TestRunner defines a test runner.
func NewTestRunner ¶
func NewTestRunner( files []string, fw *filewatcher.FileWatcher, onFileChange func(), ) (*TestRunner, error)
NewTestRunner creates a new test runner.
func (*TestRunner) AddOutput ¶
func (t *TestRunner) AddOutput(output []string) []string
AddOutput adds output lines to the output buffer.
func (*TestRunner) GetCoverage ¶
func (t *TestRunner) GetCoverage() float64
GetCoverage gets the overall coverage percentage from the last test run.
func (*TestRunner) GetFiles ¶
func (t *TestRunner) GetFiles() map[string]File
GetFiles gets the files.
func (*TestRunner) GetFuncCoveragePercentages ¶
func (t *TestRunner) GetFuncCoveragePercentages( coverageFile string, ) (map[string]map[string]float64, float64, error)
GetFuncCoveragePercentages gets coverage percentages for each function.
func (*TestRunner) GetHasRunTests ¶
func (t *TestRunner) GetHasRunTests() bool
GetHasRunTests checks if tests have been run.
func (*TestRunner) GetIsRunning ¶
func (t *TestRunner) GetIsRunning() bool
GetIsRunning checks if tests are currently running.
func (*TestRunner) GetOutput ¶
func (t *TestRunner) GetOutput() []string
GetOutput gets the output buffer.
func (*TestRunner) ParseCoverage ¶
func (t *TestRunner) ParseCoverage(coverageFile string) ([]CoverageLine, error)
ParseCoverage parses the coverage report.
func (*TestRunner) ParseCoverageLines ¶
func (t *TestRunner) ParseCoverageLines( coverageLines []CoverageLine, coveragePercentages map[string]map[string]float64, ) []File
ParseCoverageLines parses the coverage lines.
func (*TestRunner) ParseErrorFromOutput ¶
func (t *TestRunner) ParseErrorFromOutput(output string) string
ParseErrorFromOutput extracts error messages from the output.
func (*TestRunner) RunAllTests ¶
func (t *TestRunner) RunAllTests( testCompleteCallback func(file File) error, outputCallback func(output string) error, completionCallback func(), )
RunAllTests runs all tests.
func (*TestRunner) SetCoverage ¶
func (t *TestRunner) SetCoverage(coverage float64)
SetCoverage sets the overall coverage percentage.
func (*TestRunner) SetHasRunTests ¶
func (t *TestRunner) SetHasRunTests(hasRunTests bool)
SetHasRunTests sets if tests have been run.
func (*TestRunner) SetIsRunning ¶
func (t *TestRunner) SetIsRunning(running bool)
SetIsRunning sets if tests are running.
func (*TestRunner) SetOnFileChange ¶
func (t *TestRunner) SetOnFileChange(callback func())
SetOnFileChange sets the file change callback.
func (*TestRunner) StopTests ¶
func (t *TestRunner) StopTests()
StopTests stops the currently running tests.
Source Files
¶
- add_output.go
- close.go
- file.go
- function.go
- get_coverage.go
- get_files.go
- get_func_coverage_percentages.go
- get_functions_from_file.go
- get_functions_from_files.go
- get_has_run_tests.go
- get_is_running.go
- get_module_name.go
- get_output.go
- get_overall_coverage_percentage.go
- handle_file_event.go
- highlight_code.go
- parse_coverage.go
- parse_coverage_lines.go
- parse_error_from_output.go
- parse_failed_test_files_from_output.go
- process_file_event.go
- run_all_tests.go
- set_coverage.go
- set_has_run_tests.go
- set_is_running.go
- set_on_file_change.go
- stop_tests.go
- testrunner.go