mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-01 13:59:37 +08:00
feat: support set debug for runner
This commit is contained in:
@@ -17,12 +17,14 @@ func Test(t *testing.T, testcases ...*TestCase) error {
|
||||
func NewRunner() *Runner {
|
||||
return &Runner{
|
||||
t: &testing.T{},
|
||||
debug: false, // default to turn off debug
|
||||
Client: req.New(),
|
||||
}
|
||||
}
|
||||
|
||||
type Runner struct {
|
||||
t *testing.T
|
||||
debug bool
|
||||
Client *req.Req
|
||||
}
|
||||
|
||||
@@ -31,6 +33,11 @@ func (r *Runner) WithTestingT(t *testing.T) *Runner {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Runner) SetDebug(debug bool) *Runner {
|
||||
r.debug = debug
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Runner) Run(testcases ...*TestCase) error {
|
||||
for _, testcase := range testcases {
|
||||
if err := r.runCase(testcase); err != nil {
|
||||
@@ -93,7 +100,7 @@ func (r *Runner) runStepRequest(step *TStep) error {
|
||||
}
|
||||
|
||||
// do request action
|
||||
req.Debug = true
|
||||
req.Debug = r.debug
|
||||
resp, err := r.Client.Do(string(step.Request.Method), step.Request.URL, v...)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user