Skip to content

Commit d1b61c1

Browse files
authored
Merge pull request #119 from ozontech/118-table-test-not-working
Run BeforeAll hook before collecting table tests
2 parents 4c48f2f + c81fe67 commit d1b61c1

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

pkg/framework/runner/runner.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import (
1818
)
1919

2020
type runner struct {
21-
internalT internalT
22-
testPlan *testplan.TestPlan
23-
tests map[string]Test
21+
internalT internalT
22+
testPlan *testplan.TestPlan
23+
tests map[string]Test
24+
adjustTableTests func()
2425
}
2526

2627
func NewRunner(realT TestingT, suiteName string) TestRunner {
@@ -127,13 +128,6 @@ func (r *runner) RunTests() SuiteResult {
127128

128129
defer r.t().SetRealT(oldParentT)
129130

130-
r.tests = r.filterByTestPlan()
131-
132-
if len(r.tests) == 0 {
133-
r.t().Skipf("No tests to run for suite %s", r.t().Name())
134-
return
135-
}
136-
137131
defer wg.Wait()
138132
defer finishSuite(r.internalT.GetProvider())
139133
defer func() { _, _ = runHook(r.t(), afterAllHook) }()
@@ -169,6 +163,17 @@ func (r *runner) RunTests() SuiteResult {
169163
return
170164
}
171165

166+
if r.adjustTableTests != nil {
167+
r.adjustTableTests()
168+
}
169+
170+
r.tests = r.filterByTestPlan()
171+
172+
if len(r.tests) == 0 {
173+
r.t().Skipf("No tests to run for suite %s", r.t().Name())
174+
return
175+
}
176+
172177
// HACK: t.Parallel() waits for parent-test reach its defer function
173178
// Unfortunately it's impossible to reach this function if parent-test waits for other tests complete
174179
// So if we run child test from test-runner

pkg/framework/runner/suite_runner.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ func newSuiteRunner(
8787
suite: suite,
8888
}
8989

90+
r.adjustTableTests = func() {
91+
initializeParametrizedTests(r)
92+
}
93+
9094
collectTests(r, suite)
9195
collectParametrizedTests(r, suite)
9296
collectHooks(r, suite)
@@ -160,9 +164,8 @@ func parametrizedWrap(runner *suiteRunner, beforeAll func(provider.T)) func(t pr
160164
func collectParametrizedTests(runner *suiteRunner, suite TestSuite) {
161165
if ps, ok := suite.(ParametrizedSuite); ok {
162166
ps.InitializeTestsParams()
167+
initializeParametrizedTests(runner)
163168
}
164-
165-
initializeParametrizedTests(runner)
166169
}
167170

168171
func initializeParametrizedTests(runner *suiteRunner) {

0 commit comments

Comments
 (0)