mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-14 12:07:41 +08:00
refactor: runner api
This commit is contained in:
18
runner.go
18
runner.go
@@ -18,13 +18,17 @@ import (
|
||||
)
|
||||
|
||||
// run API test with default configs
|
||||
func Run(t *testing.T, testcases ...ITestCase) error {
|
||||
return NewRunner().WithTestingT(t).SetDebug(true).Run(testcases...)
|
||||
func Run(testcases ...ITestCase) error {
|
||||
t := &testing.T{}
|
||||
return NewRunner(t).SetDebug(true).Run(testcases...)
|
||||
}
|
||||
|
||||
func NewRunner() *Runner {
|
||||
func NewRunner(t *testing.T) *Runner {
|
||||
if t == nil {
|
||||
t = &testing.T{}
|
||||
}
|
||||
return &Runner{
|
||||
t: &testing.T{},
|
||||
t: t,
|
||||
debug: false, // default to turn off debug
|
||||
client: &http.Client{
|
||||
Transport: &http.Transport{
|
||||
@@ -41,12 +45,6 @@ type Runner struct {
|
||||
client *http.Client
|
||||
}
|
||||
|
||||
func (r *Runner) WithTestingT(t *testing.T) *Runner {
|
||||
log.Info().Msg("[init] WithTestingT")
|
||||
r.t = t
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Runner) SetDebug(debug bool) *Runner {
|
||||
log.Info().Bool("debug", debug).Msg("[init] SetDebug")
|
||||
r.debug = debug
|
||||
|
||||
Reference in New Issue
Block a user