Skip to content

Commit

Permalink
[ISSUE-41] unit test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Natalia Ugolnikova committed Feb 6, 2023
1 parent 6916860 commit 85193d5
Showing 1 changed file with 32 additions and 3 deletions.
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 85193d5

Please sign in to comment.