Skip to content

Commit

Permalink
Merge pull request #56 from nugolnikova/release/issue-41
Browse files Browse the repository at this point in the history
[ISSUE-41] duration of consistent tests in suite fixed. Info about status Unknown added to pkg/allure/README.  go.mod/go.sum updated
  • Loading branch information
koodeex authored Feb 7, 2023
2 parents 9592417 + 85193d5 commit 3a59f83
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ replace (
require (
github.com/jackc/fake v0.0.0-20150926172116-812a484cc733
github.com/ozontech/allure-go/pkg/allure v0.6.4
github.com/ozontech/allure-go/pkg/framework v0.6.18
github.com/ozontech/allure-go/pkg/framework v0.6.19
)

require (
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
2 changes: 2 additions & 0 deletions pkg/allure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Supported test statuses:
| `Broken` | `broken` |
| `Unknown` | `unknown` |

NOTE: Tests failed in the BeforeAll/BeforeEach functions have the status Unknown

## Attachment

[`allure.Attachment`](attachment.go) - is the implementation of the appendices to the report in allure. It is most often used to contain
Expand Down
1 change: 0 additions & 1 deletion pkg/allure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)
7 changes: 0 additions & 7 deletions pkg/allure/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -9,16 +8,10 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion pkg/framework/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (r *runner) RunTests() SuiteResult {
for _, testData := range r.tests {
test := testData
wg.Add(1)
r.realT().Run(test.GetMeta().GetResult().Name, func(t *testing.T) {
r.realT().Run(test.GetMeta().GetResult().Begin().Name, func(t *testing.T) {
defer wg.Done()
defer func() {
result.NewResult(finishTest(t, test.GetMeta()))
Expand Down
35 changes: 32 additions & 3 deletions pkg/framework/suite/suite_runner_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package suite

import (
"github.com/ozontech/allure-go/pkg/framework/runner"
"os"
"sync"
"testing"

"github.com/stretchr/testify/require"
"time"

"github.com/ozontech/allure-go/pkg/framework/provider"
"github.com/ozontech/allure-go/pkg/framework/runner"
"github.com/stretchr/testify/require"
)

type suiteRunnerTMock struct {
Expand Down Expand Up @@ -139,3 +139,32 @@ func TestRunner_hooks(t *testing.T) {
require.True(t, suite.afterAll)
require.True(t, suite.testSome1)
}

type TestSuiteStartTimeOfConsistentTests struct {
Suite
}

func (s *TestSuiteStartTimeOfConsistentTests) TestSome1(t provider.T) {
t.WithNewStep("step 1", func(sCtx provider.StepCtx) {
time.Sleep(1 * time.Second)
})
}

func (s *TestSuiteStartTimeOfConsistentTests) TestSome2(t provider.T) {
t.WithNewStep("step 2", func(sCtx provider.StepCtx) {
time.Sleep(1 * time.Second)
})
}

func TestSuiteRunner_StartTimeAndDurationOfConsistentTests(t *testing.T) {
allureDir := "./allure-results"
defer os.RemoveAll(allureDir)

suite := new(TestSuiteStartTimeOfConsistentTests)
r := runner.NewSuiteRunner(t, "packageName", "suiteName", suite)
results := r.RunTests().GetAllTestResults()

require.True(t, results[1].GetResult().Start-results[0].GetResult().Stop <= 15)
require.Equal(t, time.UnixMilli(results[0].GetResult().Stop-results[0].GetResult().Start).Second(), 1)
require.Equal(t, time.UnixMilli(results[1].GetResult().Stop-results[1].GetResult().Start).Second(), 1)
}

0 comments on commit 3a59f83

Please sign in to comment.