Fixed an issue with calculating time for junit testsuite
Этот коммит содержится в:
родитель
849e8e499b
коммит
e61d3558c6
2 изменённых файлов: 12 добавлений и 23 удалений
|
@ -1,8 +1,6 @@
|
|||
package godog
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cucumber/messages-go/v10"
|
||||
)
|
||||
|
||||
|
@ -10,7 +8,6 @@ type feature struct {
|
|||
*messages.GherkinDocument
|
||||
pickles []*messages.Pickle
|
||||
|
||||
time time.Time
|
||||
content []byte
|
||||
order int
|
||||
}
|
||||
|
@ -90,7 +87,3 @@ func (f feature) findStep(astStepID string) *messages.GherkinDocument_Feature_St
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f feature) startedAt() time.Time {
|
||||
return f.time
|
||||
}
|
||||
|
|
28
fmt_junit.go
28
fmt_junit.go
|
@ -67,21 +67,8 @@ func (f *junitFormatter) buildJUNITPackageSuite() junitPackageSuite {
|
|||
pickles := f.storage.mustGetPickles(feature.Uri)
|
||||
sort.Sort(sortPicklesByID(pickles))
|
||||
|
||||
var finishedAt = feature.startedAt()
|
||||
|
||||
if len(pickles) > 0 {
|
||||
lastPickle := pickles[len(pickles)-1]
|
||||
|
||||
if len(lastPickle.Steps) > 0 {
|
||||
lastStep := lastPickle.Steps[len(lastPickle.Steps)-1]
|
||||
lastPickleStepResult := f.storage.mustGetPickleStepResult(lastStep.Id)
|
||||
finishedAt = lastPickleStepResult.finishedAt
|
||||
}
|
||||
}
|
||||
|
||||
ts := junitTestSuite{
|
||||
Name: feature.Feature.Name,
|
||||
Time: junitTimeDuration(feature.startedAt(), finishedAt),
|
||||
TestCases: make([]*junitTestCase, len(pickles)),
|
||||
}
|
||||
|
||||
|
@ -90,21 +77,28 @@ func (f *junitFormatter) buildJUNITPackageSuite() junitPackageSuite {
|
|||
testcaseNames[pickle.Name] = testcaseNames[pickle.Name] + 1
|
||||
}
|
||||
|
||||
firstPickleStartedAt := f.startedAt
|
||||
lastPickleFinishedAt := f.startedAt
|
||||
|
||||
var outlineNo = make(map[string]int)
|
||||
for idx, pickle := range pickles {
|
||||
tc := junitTestCase{}
|
||||
|
||||
pickleResult := f.storage.mustGetPickleResult(pickle.Id)
|
||||
|
||||
var finishedAt = pickleResult.StartedAt
|
||||
if idx == 0 {
|
||||
firstPickleStartedAt = pickleResult.StartedAt
|
||||
}
|
||||
|
||||
lastPickleFinishedAt = pickleResult.StartedAt
|
||||
|
||||
if len(pickle.Steps) > 0 {
|
||||
lastStep := pickle.Steps[len(pickle.Steps)-1]
|
||||
lastPickleStepResult := f.storage.mustGetPickleStepResult(lastStep.Id)
|
||||
finishedAt = lastPickleStepResult.finishedAt
|
||||
lastPickleFinishedAt = lastPickleStepResult.finishedAt
|
||||
}
|
||||
|
||||
tc.Time = junitTimeDuration(pickleResult.StartedAt, finishedAt)
|
||||
tc.Time = junitTimeDuration(pickleResult.StartedAt, lastPickleFinishedAt)
|
||||
|
||||
tc.Name = pickle.Name
|
||||
if testcaseNames[tc.Name] > 1 {
|
||||
|
@ -159,6 +153,8 @@ func (f *junitFormatter) buildJUNITPackageSuite() junitPackageSuite {
|
|||
ts.TestCases[idx] = &tc
|
||||
}
|
||||
|
||||
ts.Time = junitTimeDuration(firstPickleStartedAt, lastPickleFinishedAt)
|
||||
|
||||
suite.TestSuites[idx] = &ts
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче