Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type APICallFunc ¶
接口调用函数回调,用于调用API并设置返回值等,在 Pre-Script 执行完之后调用 如果接口调用失败,返回Error data 必须是一个可以被 JSON marshall 的数据,比如 struct 、map 等
type GlobalStore ¶
type GlobalStore struct {
// contains filtered or unexported fields
}
GlobalStore 用于测试用例在执行过程中设置全局变量从而在测试用例之间共享数据
func NewGlobalStore ¶
func NewGlobalStore() *GlobalStore
func (*GlobalStore) Get ¶
func (g *GlobalStore) Get(key string) (value interface{})
func (*GlobalStore) Set ¶
func (g *GlobalStore) Set(key string, value interface{})
type Interpreter ¶
type Interpreter interface { // 设置 Execute(context context.Context, script TestScript, handler APICallFunc) (result TestResult) // 注册脚本函数 RegisterFunc(name string, f interface{}) error }
type InterpreterType ¶
type InterpreterType string
const (
InterpreterTypeJS InterpreterType = "javascript"
)
type JSInterpreter ¶
type JSInterpreter struct {
// contains filtered or unexported fields
}
func NewJSInterpreter ¶
func NewJSInterpreter(gs *GlobalStore) *JSInterpreter
func (*JSInterpreter) Execute ¶
func (j *JSInterpreter) Execute(ctx context.Context, script TestScript, handler APICallFunc) (result TestResult)
func (*JSInterpreter) RegisterFunc ¶
func (j *JSInterpreter) RegisterFunc(name string, f interface{}) error
func (*JSInterpreter) Set ¶
func (j *JSInterpreter) Set(name string, value interface{}) error
type Option ¶
type Option func(t *XTest)
func WithGlobalStore ¶
func WithInterpreter ¶
func WithInterpreter(interpreterType InterpreterType) Option
type TestResult ¶
type XTest ¶
type XTest struct {
// contains filtered or unexported fields
}
func (*XTest) Interpreter ¶
func (t *XTest) Interpreter() Interpreter
func (*XTest) Run ¶
func (t *XTest) Run(c context.Context, script TestScript, handler APICallFunc) (result TestResult)
Click to show internal directories.
Click to hide internal directories.