mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 13:29:35 +08:00
fix: output html report path optimization and failed to extract variables to session while load testing
This commit is contained in:
@@ -125,7 +125,7 @@ func (b *HRPBoomer) convertBoomerTask(testcase *TestCase, rendezvousList []*Rend
|
||||
transactionSuccess = false
|
||||
|
||||
if b.hrpRunner.failfast {
|
||||
log.Error().Msg("abort running due to failfast setting")
|
||||
log.Error().Err(err).Msg("abort running due to failfast setting")
|
||||
break
|
||||
}
|
||||
log.Warn().Err(err).Msg("run step failed, continue next step")
|
||||
@@ -148,6 +148,10 @@ func (b *HRPBoomer) convertBoomerTask(testcase *TestCase, rendezvousList []*Rend
|
||||
} else {
|
||||
// request or testcase step
|
||||
b.RecordSuccess(string(step.Type()), step.Name(), stepResult.Elapsed, stepResult.ContentSize)
|
||||
// update extracted variables
|
||||
for k, v := range stepResult.ExportVars {
|
||||
sessionRunner.sessionVariables[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
endTime := time.Now()
|
||||
|
||||
@@ -182,6 +182,14 @@ func (r *HRPRunner) Run(testcases ...ITestCase) error {
|
||||
}
|
||||
s.Time.Duration = time.Since(s.Time.StartAt).Seconds()
|
||||
|
||||
// update the report output path
|
||||
pluginPath, err := locatePlugin(testcases[0].GetPath())
|
||||
if err == nil {
|
||||
outputPath, _ := filepath.Split(pluginPath)
|
||||
summaryPath = filepath.Join(outputPath, summaryPath)
|
||||
reportPath = filepath.Join(outputPath, reportPath)
|
||||
}
|
||||
|
||||
// save summary
|
||||
if r.saveTests {
|
||||
dir, _ := filepath.Split(summaryPath)
|
||||
|
||||
@@ -61,7 +61,8 @@ func (s *Summary) genHTMLReport() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
file, err := os.OpenFile(fmt.Sprintf(reportPath, s.Time.StartAt.Unix()), os.O_WRONLY|os.O_CREATE, 0666)
|
||||
reportPath := fmt.Sprintf(reportPath, s.Time.StartAt.Unix())
|
||||
file, err := os.OpenFile(reportPath, os.O_WRONLY|os.O_CREATE, 0666)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("open file failed")
|
||||
return err
|
||||
@@ -75,15 +76,20 @@ func (s *Summary) genHTMLReport() error {
|
||||
return err
|
||||
}
|
||||
err = writer.Flush()
|
||||
if err == nil {
|
||||
log.Info().Str("path", reportPath).Msg("generate HTML report")
|
||||
} else {
|
||||
log.Error().Str("path", reportPath).Msg("generate HTML report failed")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
//go:embed internal/scaffold/templates/report/template.html
|
||||
var reportTemplate string
|
||||
|
||||
const (
|
||||
reportPath string = "reports/report-%v.html"
|
||||
summaryPath string = "reports/summary-%v.json"
|
||||
var (
|
||||
reportPath = "reports/report-%v.html"
|
||||
summaryPath = "reports/summary-%v.json"
|
||||
)
|
||||
|
||||
type Stat struct {
|
||||
|
||||
Reference in New Issue
Block a user