Skip to content

Commit

Permalink
[ISSUE-84] add getRealT
Browse files Browse the repository at this point in the history
  • Loading branch information
siller174 committed Mar 17, 2024
1 parent 592bb00 commit 7bb626c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
5 changes: 0 additions & 5 deletions pkg/framework/core/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ func (c *Common) SkipOnPrint() {
c.GetResult().SkipOnPrint()
}

// Helper ...
func (c *Common) Helper() {
c.TestingT.Helper()
}

// LogStep ...
func (c *Common) LogStep(args ...interface{}) {
c.Provider.Step(allure.NewSimpleStep(fmt.Sprintln(args...)))
Expand Down
1 change: 1 addition & 0 deletions pkg/framework/core/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ type commonTMock struct {
parallel bool
run bool
skipped bool
TestingT *testing.T
}

func newCommonTMock() *commonTMock {
Expand Down
9 changes: 4 additions & 5 deletions pkg/framework/core/common/step_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type StepT interface {
Broken()
BrokenNow()
Name() string
Helper()
GetRealT() provider.TestingT
}

Expand Down Expand Up @@ -92,10 +91,6 @@ func (ctx *stepCtx) FailNow() {
ctx.t.FailNow()
}

func (ctx *stepCtx) Helper() {
ctx.t.GetRealT().Helper()
}

func (ctx *stepCtx) Error(args ...interface{}) {
ctx.t.GetRealT().Helper()

Expand Down Expand Up @@ -226,3 +221,7 @@ func (ctx *stepCtx) Breakf(format string, args ...interface{}) {
ctx.Broken()
ctx.t.Breakf(format, args...)
}

func (ctx *stepCtx) GetRealT() provider.TestingT {
return ctx.t.GetRealT()
}
8 changes: 5 additions & 3 deletions pkg/framework/core/common/step_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ func (m *providerTMockStep) Name() string {
return m.name
}

func (m *providerTMockStep) Helper() {
}

func (m *providerTMockStep) GetRealT() provider.TestingT {
return m.testingT
}
Expand Down Expand Up @@ -262,6 +259,7 @@ func TestStepCtx_Errorf_withParent(t *testing.T) {

func TestStepCtx_Errorf_noParent(t *testing.T) {
mockT := new(providerTMockStep)
mockT.SetRealT(t)
step := allure.NewSimpleStep("testStep")
ctx := stepCtx{t: mockT, currentStep: step}
ctx.Errorf("test")
Expand All @@ -271,6 +269,8 @@ func TestStepCtx_Errorf_noParent(t *testing.T) {

func TestStepCtx_Error_withParent(t *testing.T) {
mockT := new(providerTMockStep)
mockT.SetRealT(t)

parentStep := allure.NewSimpleStep("parentStep", allure.NewParameters("paramParent1", "v1", "paramParent2", "v2")...)
parentCtx := &stepCtx{t: mockT, currentStep: parentStep}
step := allure.NewSimpleStep("testStep")
Expand All @@ -283,6 +283,8 @@ func TestStepCtx_Error_withParent(t *testing.T) {

func TestStepCtx_Error_noParent(t *testing.T) {
mockT := new(providerTMockStep)
mockT.SetRealT(t)

step := allure.NewSimpleStep("testStep")
ctx := stepCtx{t: mockT, currentStep: step}
ctx.Error("test")
Expand Down
1 change: 0 additions & 1 deletion pkg/framework/provider/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ type StepCtx interface {
Break(args ...interface{})
Breakf(format string, args ...interface{})
Name() string
Helper()
}

// Asserts ...
Expand Down

0 comments on commit 7bb626c

Please sign in to comment.