mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
feat: support setting global testcase timeout and step timeout
This commit is contained in:
@@ -143,6 +143,13 @@ func (r *HRPRunner) SetProxyUrl(proxyUrl string) *HRPRunner {
|
||||
return r
|
||||
}
|
||||
|
||||
// SetTimeout configures global timeout in seconds.
|
||||
func (r *HRPRunner) SetTimeout(timeout time.Duration) *HRPRunner {
|
||||
log.Info().Float64("timeout(seconds)", timeout.Seconds()).Msg("[init] SetTimeout")
|
||||
r.httpClient.Timeout = timeout
|
||||
return r
|
||||
}
|
||||
|
||||
// SetSaveTests configures whether to save summary of tests.
|
||||
func (r *HRPRunner) SetSaveTests(saveTests bool) *HRPRunner {
|
||||
log.Info().Bool("saveTests", saveTests).Msg("[init] SetSaveTests")
|
||||
@@ -260,6 +267,12 @@ func (r *HRPRunner) newCaseRunner(testcase *TestCase) (*testCaseRunner, error) {
|
||||
return nil, errors.Wrap(err, "parse testcase config failed")
|
||||
}
|
||||
|
||||
// set testcase timeout in seconds
|
||||
if runner.testCase.Config.Timeout != 0 {
|
||||
timeout := time.Duration(runner.testCase.Config.Timeout*1000) * time.Millisecond
|
||||
runner.hrpRunner.SetTimeout(timeout)
|
||||
}
|
||||
|
||||
return runner, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user