Documentation
¶
Index ¶
- Variables
- func BoolVarFromCtx(ctx context.Context, varname string) bool
- func Debug(ctx context.Context, format string, args ...interface{})
- func Dump(va interface{}) (map[string]interface{}, error)
- func DumpString(va interface{}) (map[string]string, error)
- func DumpStringPreserveCase(va interface{}) (map[string]string, error)
- func DumpWithPrefix(va interface{}, prefix string) (map[string]interface{}, error)
- func Error(ctx context.Context, format string, args ...interface{})
- func Fatal(ctx context.Context, format string, args ...interface{})
- func GetExecutorResult(r interface{}) map[string]interface{}
- func HideSensitive(ctx context.Context, arg interface{}) string
- func Info(ctx context.Context, format string, args ...interface{})
- func InitTestLogger(t *testing.T)
- func IntVarFromCtx(ctx context.Context, varname string) int
- func JSONUnmarshal(btes []byte, i interface{}) error
- func OSExit(exitCode int)
- func RemoveNotPrintableChar(in string) string
- func StringMapInterfaceVarFromCtx(ctx context.Context, varname string) map[string]interface{}
- func StringMapStringVarFromCtx(ctx context.Context, varname string) map[string]string
- func StringSliceVarFromCtx(ctx context.Context, varname string) []string
- func StringVarFromCtx(ctx context.Context, varname string) string
- func VarFromCtx(ctx context.Context, varname string) interface{}
- func Warn(ctx context.Context, format string, args ...interface{})
- func Warning(ctx context.Context, format string, args ...interface{})
- func WithFormatterLowerFirstKey() dump.KeyFormatterFunc
- type Assertion
- type AssertionApplied
- type AssertionsApplied
- type AssignStep
- type Assignment
- type ContextKey
- type Executor
- type ExecutorRunner
- type ExecutorWithSetup
- type Failure
- type FailureXML
- type H
- type InnerResult
- type Range
- type RangeData
- type Skipped
- type Status
- type StepAssertions
- type TestCase
- type TestCaseInput
- type TestCaseXML
- type TestStep
- type TestStepResult
- type TestSuite
- type TestSuiteInput
- type TestSuiteXML
- type Tests
- type TestsHTML
- type TestsXML
- type UserExecutor
- type Venom
- func (v *Venom) AddSecrets(secrets map[string]interface{})
- func (v *Venom) AddVariables(variables map[string]interface{})
- func (v *Venom) CleanUpSecrets(testSuite TestSuite) TestSuite
- func (v *Venom) GetExecutorRunner(ctx context.Context, ts TestStep, h H) (context.Context, ExecutorRunner, error)
- func (v *Venom) InitLogger() error
- func (v *Venom) OutputResult() error
- func (v *Venom) Parse(ctx context.Context, path []string) error
- func (v *Venom) Print(format string, a ...interface{})
- func (v *Venom) Println(format string, a ...interface{})
- func (v *Venom) PrintlnIndentedTrace(s string, indent string)
- func (v *Venom) PrintlnTrace(s string)
- func (v *Venom) Process(ctx context.Context, path []string) error
- func (v *Venom) RegisterExecutorBuiltin(name string, e Executor)
- func (v *Venom) RegisterExecutorPlugin(name string, e Executor)
- func (v *Venom) RegisterExecutorUser(name string, e Executor) error
- func (v *Venom) RunTestStep(ctx context.Context, e ExecutorRunner, tc *TestCase, tsResult *TestStepResult, ...)
- func (v *Venom) RunUserExecutor(ctx context.Context, runner ExecutorRunner, tcIn *TestCase, ...) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
var ( Red = color.New(color.FgRed).SprintFunc() Yellow = color.New(color.FgYellow).SprintFunc() Green = color.New(color.FgGreen).SprintFunc() Cyan = color.New(color.FgCyan).SprintFunc() Gray = color.New(color.Attribute(90)).SprintFunc() )
var ( // Version is set with -ldflags "-X github.com/ovh/venom/venom.Version=$(VERSION)" Version = "snapshot" IsTest = "" )
Functions ¶
func DumpString ¶ added in v1.0.0
DumpString dumps v as a map[string]string{}, key in lowercase
func DumpStringPreserveCase ¶ added in v1.0.0
DumpStringPreserveCase dumps v as a map[string]string{}
func DumpWithPrefix ¶ added in v1.1.0
Dump dumps v as a map[string]interface{}.
func GetExecutorResult ¶ added in v1.0.0
func GetExecutorResult(r interface{}) map[string]interface{}
func HideSensitive ¶ added in v1.2.0
HideSensitive replace the value with __hidden__
func InitTestLogger ¶ added in v1.0.0
func JSONUnmarshal ¶ added in v1.0.0
func RemoveNotPrintableChar ¶ added in v0.16.0
RemoveNotPrintableChar removes not printable character from a string
func StringMapInterfaceVarFromCtx ¶ added in v1.0.0
func StringMapStringVarFromCtx ¶ added in v1.0.0
func StringSliceVarFromCtx ¶ added in v1.0.0
func StringVarFromCtx ¶ added in v1.0.0
func VarFromCtx ¶ added in v1.0.0
func WithFormatterLowerFirstKey ¶ added in v1.1.0
func WithFormatterLowerFirstKey() dump.KeyFormatterFunc
Types ¶
type Assertion ¶ added in v1.1.0
type Assertion interface{}
Assertion (usually a string, but could be a dictionary when using logical operators)
type AssertionApplied ¶ added in v1.1.0
type AssertionsApplied ¶ added in v1.1.0
type AssertionsApplied struct {
OK bool `json:"ok" yml:"-"`
Assertions []AssertionApplied `json:"assertions" yml:"-"`
// contains filtered or unexported fields
}
type AssignStep ¶ added in v0.27.0
type AssignStep struct {
Assignments map[string]Assignment `json:"vars" yaml:"vars" mapstructure:"vars"`
}
type Assignment ¶ added in v0.27.0
type ContextKey ¶
type ContextKey string
ContextKey can be added in context to store contextual infos. Also used by logger.
type Executor ¶
type Executor interface {
// Run run a Test Step
Run(context.Context, TestStep) (interface{}, error)
}
Executor execute a testStep.
type ExecutorRunner ¶ added in v1.0.0
type ExecutorWithSetup ¶ added in v1.0.0
type Failure ¶
type Failure struct {
TestcaseClassname string `xml:"-" json:"-" yaml:"-"`
TestcaseName string `xml:"-" json:"-" yaml:"-"`
TestcaseLineNumber int `xml:"-" json:"-" yaml:"-"`
StepNumber int `xml:"-" json:"-" yaml:"-"`
Assertion string `xml:"-" json:"-" yaml:"-"`
AssertionRequired bool `xml:"-" json:"-" yaml:"-"`
Error error `xml:"-" json:"-" yaml:"-"`
Value string `json:"value" yaml:"value,omitempty"`
}
Failure contains data related to a failed test.
type FailureXML ¶ added in v1.1.0
type H ¶ added in v0.27.0
type H map[string]interface{}
func AllVarsFromCtx ¶ added in v1.0.0
func (*H) AddAllWithPrefix ¶ added in v0.27.0
func (*H) AddWithPrefix ¶ added in v0.27.0
type InnerResult ¶
type InnerResult struct {
Value string `xml:",cdata" json:"value" yaml:"value"`
}
InnerResult is used by TestCase
type RangeData ¶ added in v1.1.0
type RangeData struct {
Key string
Value interface{}
}
RangeData contains a single iterable user value
type Skipped ¶ added in v0.16.0
type Skipped struct {
Value string `xml:",cdata" json:"value" yaml:"value,omitempty"`
}
Skipped contains data related to a skipped test.
type StepAssertions ¶
type StepAssertions struct {
Assertions []Assertion `json:"assertions,omitempty" yaml:"assertions,omitempty"`
}
StepAssertions contains step assertions
type TestCase ¶
type TestCase struct {
TestCaseInput
Skipped []Skipped `json:"skipped" yaml:"-"`
Status Status `json:"status" yaml:"-"`
Duration float64 `json:"duration" yaml:"-"`
Start time.Time `json:"start" yaml:"-"`
End time.Time `json:"end" yaml:"-"`
TestStepResults []TestStepResult `json:"results" yaml:"-"`
TestSuiteVars H `json:"-" yaml:"-"`
IsExecutor bool `json:"-" yaml:"-"`
IsEvaluated bool `json:"-" yaml:"-"`
// contains filtered or unexported fields
}
type TestCaseInput ¶ added in v1.1.0
type TestCaseXML ¶ added in v1.1.0
type TestCaseXML struct {
XMLName xml.Name `xml:"testcase" json:"-" yaml:"-"`
Classname string `xml:"classname,attr,omitempty" json:"classname" yaml:"-"`
Errors []FailureXML `xml:"error,omitempty" json:"errors" yaml:"errors,omitempty"`
Failures []FailureXML `xml:"failure,omitempty" json:"failures" yaml:"failures,omitempty"`
Name string `xml:"name,attr" json:"name" yaml:"name"`
Skipped []Skipped `xml:"skipped,omitempty" json:"skipped" yaml:"skipped,omitempty"`
Systemout InnerResult `xml:"system-out,omitempty" json:"systemout" yaml:"systemout,omitempty"`
Systemerr InnerResult `xml:"system-err,omitempty" json:"systemerr" yaml:"systemerr,omitempty"`
Time float64 `xml:"time,attr,omitempty" json:"time" yaml:"time,omitempty"`
ID string `xml:"id,attr,omitempty" json:"id" yaml:"id"`
}
TestCase is a single test case with its result.
type TestStep ¶
type TestStep map[string]interface{}
TestStep represents a testStep
func (TestStep) StringSliceValue ¶ added in v1.0.0
type TestStepResult ¶ added in v1.1.0
type TestStepResult struct {
Name string `json:"name"`
Errors []Failure `json:"errors"`
Skipped []Skipped `json:"skipped" yaml:"skipped"`
Status Status `json:"status" yaml:"status"`
Raw interface{} `json:"raw" yaml:"raw"`
Interpolated interface{} `json:"interpolated" yaml:"interpolated"`
Number int `json:"number" yaml:"number"`
RangedIndex int `json:"rangedIndex" yaml:"rangedIndex"`
RangedEnable bool `json:"rangedEnable" yaml:"rangedEnable"`
InputVars map[string]string `json:"inputVars" yaml:"-"`
ComputedVars H `json:"computedVars" yaml:"-"`
ComputedInfo []string `json:"computedInfos" yaml:"-"`
AssertionsApplied AssertionsApplied `json:"assertionsApplied" yaml:"-"`
Retries int `json:"retries" yaml:"retries"`
Systemout string `json:"systemout"`
Systemerr string `json:"systemerr"`
Duration float64 `json:"duration"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
}
type TestSuite ¶
type TestSuite struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description"`
TestCases []TestCase `json:"testcases" yaml:"testcases"`
Vars H `json:"vars" yaml:"vars"`
Secrets []string `json:"secrets" yaml:"secrets"`
// computed
ShortName string `json:"shortname" yaml:"-"`
Filename string `json:"filename" yaml:"-"`
Filepath string `json:"filepath" yaml:"-"`
ComputedVars H `json:"computed_vars" yaml:"-"`
WorkDir string `json:"workdir" yaml:"_"`
Status Status `json:"status" yaml:"status"`
Duration float64 `json:"duration" yaml:"-"`
Start time.Time `json:"start" yaml:"-"`
End time.Time `json:"end" yaml:"-"`
NbTestcasesFail int `json:"nbTestcasesFail" yaml:"-"`
NbTestcasesPass int `json:"nbTestcasesPass" yaml:"-"`
NbTestcasesSkip int `json:"nbTestcasesSkip" yaml:"-"`
}
type TestSuiteInput ¶ added in v1.1.0
type TestSuiteInput struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
TestCases []TestCaseInput `json:"testcases" yaml:"testcases"`
Vars H `json:"vars" yaml:"vars"`
Secrets []string `json:"secrets" yaml:"secrets"`
}
type TestSuiteXML ¶ added in v1.1.0
type TestSuiteXML struct {
XMLName xml.Name `xml:"testsuite" json:"-" yaml:"-"`
Disabled int `xml:"disabled,attr,omitempty" json:"disabled" yaml:""`
Errors int `xml:"errors,attr,omitempty" json:"errors" yaml:"-"`
Failures int `xml:"failures,attr,omitempty" json:"failures" yaml:"-"`
Hostname string `xml:"hostname,attr,omitempty" json:"hostname" yaml:"-"`
ID string `xml:"id,attr,omitempty" json:"id" yaml:"-"`
Name string `xml:"name,attr" json:"name" yaml:"name"`
Package string `xml:"package,attr,omitempty" json:"package" yaml:"-"`
Skipped int `xml:"skipped,attr,omitempty" json:"skipped" yaml:"skipped,omitempty"`
Total int `xml:"tests,attr" json:"total" yaml:"total,omitempty"`
TestCases []TestCaseXML `xml:"testcase" json:"testcases" yaml:"testcases"`
Version string `xml:"version,omitempty" json:"version" yaml:"version,omitempty"`
Time string `xml:"time,attr,omitempty" json:"time" yaml:"-"`
Timestamp string `xml:"timestamp,attr,omitempty" json:"timestamp" yaml:"-"`
}
TestSuite is a single JUnit test suite which may contain many testcases.
type Tests ¶
type Tests struct {
TestSuites []TestSuite `json:"test_suites" yml:"tests_suites"`
Status Status `json:"status" yml:"status"`
NbTestsuitesFail int `json:"nbTestsuitesFail" yaml:"-"`
NbTestsuitesPass int `json:"nbTestsuitesPass" yaml:"-"`
NbTestsuitesSkip int `json:"nbTestsuitesSkip" yaml:"-"`
Duration float64 `json:"duration" yaml:"-"`
Start time.Time `json:"start" yaml:"-"`
End time.Time `json:"end" yaml:"-"`
}
type TestsXML ¶ added in v1.1.0
type TestsXML struct {
XMLName xml.Name `xml:"testsuites" json:"-" yaml:"-"`
TestSuites []TestSuiteXML `xml:"testsuite" json:"test_suites"`
}
type UserExecutor ¶ added in v1.0.0
type UserExecutor struct {
Executor string
Input H `json:"input" yaml:"input"`
TestSteps []json.RawMessage `json:"steps" yaml:"steps"`
Raw []byte `json:"-" yaml:"-"` // the raw file content of the executor
RawInputs []byte `json:"-" yaml:"-"`
Filename string `json:"-" yaml:"-"`
Output json.RawMessage `json:"output" yaml:"output"`
}
func (UserExecutor) Run ¶ added in v1.0.0
func (ux UserExecutor) Run(ctx context.Context, step TestStep) (interface{}, error)
Run is not implemented on user executor
func (UserExecutor) ZeroValueResult ¶ added in v1.0.0
func (ux UserExecutor) ZeroValueResult() interface{}
type Venom ¶ added in v0.17.0
type Venom struct {
LogOutput io.Writer
PrintFunc func(format string, a ...interface{}) (n int, err error)
Tests Tests
LibDir string
OutputFormat string
OutputDir string
StopOnFailure bool
HtmlReport bool
Verbose int
// contains filtered or unexported fields
}
func (*Venom) AddSecrets ¶ added in v1.2.0
func (*Venom) AddVariables ¶ added in v0.17.0
func (*Venom) CleanUpSecrets ¶ added in v1.2.0
CleanUpSecrets This method tries to hide all the sensitive variables
func (*Venom) GetExecutorRunner ¶ added in v1.0.0
func (v *Venom) GetExecutorRunner(ctx context.Context, ts TestStep, h H) (context.Context, ExecutorRunner, error)
GetExecutorRunner initializes a test according to its type if no type is provided, exec is default
func (*Venom) InitLogger ¶ added in v1.0.0
InitLogger initializes venom logger
func (*Venom) OutputResult ¶ added in v0.17.0
OutputResult output result to sdtout, files...
func (*Venom) PrintlnIndentedTrace ¶ added in v1.1.0
func (*Venom) PrintlnTrace ¶ added in v1.0.0
func (*Venom) RegisterExecutorBuiltin ¶ added in v1.0.0
RegisterExecutorBuiltin register builtin executors
func (*Venom) RegisterExecutorPlugin ¶ added in v1.0.0
RegisterExecutorPlugin register plugin executors
func (*Venom) RegisterExecutorUser ¶ added in v1.0.0
RegisterExecutorUser registers an user executor
func (*Venom) RunTestStep ¶ added in v0.17.0
func (v *Venom) RunTestStep(ctx context.Context, e ExecutorRunner, tc *TestCase, tsResult *TestStepResult, stepNumber int, rangedIndex int, step TestStep)
RunTestStep executes a venom testcase is a venom context
func (*Venom) RunUserExecutor ¶ added in v1.0.0
func (v *Venom) RunUserExecutor(ctx context.Context, runner ExecutorRunner, tcIn *TestCase, tsIn *TestStepResult, step TestStep) (interface{}, error)
RunUserExecutor runs a user executor with the given context, runner, test case, test step result, and step.