mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
feat: report testcase as a whole Action transaction, inspired by LoadRunner
This commit is contained in:
@@ -62,6 +62,7 @@ func (b *hrpBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
|
|||||||
Weight: config.Weight,
|
Weight: config.Weight,
|
||||||
Fn: func() {
|
Fn: func() {
|
||||||
runner := NewRunner(nil).SetDebug(b.debug).Reset()
|
runner := NewRunner(nil).SetDebug(b.debug).Reset()
|
||||||
|
startTime := time.Now()
|
||||||
for _, step := range testcase.TestSteps {
|
for _, step := range testcase.TestSteps {
|
||||||
stepData, err := runner.runStep(step, testcase.Config)
|
stepData, err := runner.runStep(step, testcase.Config)
|
||||||
|
|
||||||
@@ -72,9 +73,8 @@ func (b *hrpBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
|
|||||||
|
|
||||||
// record transaction
|
// record transaction
|
||||||
if stepData.stepType == stepTypeTransaction {
|
if stepData.stepType == stepTypeTransaction {
|
||||||
// TODO: implement recording transaction in boomer
|
if stepData.elapsed != 0 { // only record when transaction ends
|
||||||
if stepData.elapsed != 0 {
|
b.RecordTransaction(stepData.name, stepData.elapsed, 0)
|
||||||
b.RecordSuccess(string(stepTypeTransaction), stepData.name, stepData.elapsed, 0)
|
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -96,9 +96,12 @@ func (b *hrpBoomer) convertBoomerTask(testcase *TestCase) *boomer.Task {
|
|||||||
if len(transaction) == 1 {
|
if len(transaction) == 1 {
|
||||||
// if transaction end time not exists, use testcase end time instead
|
// if transaction end time not exists, use testcase end time instead
|
||||||
duration := endTime.Sub(transaction[TransactionStart])
|
duration := endTime.Sub(transaction[TransactionStart])
|
||||||
b.RecordSuccess(string(stepTypeTransaction), name, duration.Milliseconds(), 0)
|
b.RecordTransaction(name, duration.Milliseconds(), 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// report testcase as a whole Action transaction, inspired by LoadRunner
|
||||||
|
b.RecordTransaction("Action", endTime.Sub(startTime).Milliseconds(), 0)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,9 +206,11 @@ func (r *hrpRunner) runStepTransaction(transaction *Transaction) (stepResult *st
|
|||||||
Msg("transaction")
|
Msg("transaction")
|
||||||
|
|
||||||
stepResult = &stepData{
|
stepResult = &stepData{
|
||||||
name: transaction.Name,
|
name: transaction.Name,
|
||||||
stepType: stepTypeTransaction,
|
stepType: stepTypeTransaction,
|
||||||
success: true,
|
success: true,
|
||||||
|
elapsed: 0,
|
||||||
|
responseLength: 0, // TODO: record transaction total response length
|
||||||
}
|
}
|
||||||
|
|
||||||
// create transaction if not exists
|
// create transaction if not exists
|
||||||
|
|||||||
Reference in New Issue
Block a user