diff --git a/examples/suite_demo/fails_test.go b/examples/suite_demo/fails_test.go index 2784d63..08f8d1e 100644 --- a/examples/suite_demo/fails_test.go +++ b/examples/suite_demo/fails_test.go @@ -40,6 +40,21 @@ func (s *FailsDemoSuite) TestXSkipFail(t provider.T) { t.Require().Equal(1, 2, "Assertion Failed") } +func (s *FailsDemoSuite) TestXSkipFailInStep(t provider.T) { + t.Title("This test skipped by assert inside step") + t.Description(` + This Test will be skipped with assert Error inside a step. + Error text: Assertion Failed`) + t.Tags("fail", "xskip", "assertions") + + t.XSkip() + t.WithNewStep("Failed parent step", func(ctx provider.StepCtx) { + ctx.WithNewStep("Failed child step", func(ctx provider.StepCtx) { + ctx.Require().Equal(1, 2, "Failed inside step") + }) + }) +} + func (s *FailsDemoSuite) TestAssertionFailNoMessage(t provider.T) { t.Title("This test failed by assert without message") t.Description(` diff --git a/pkg/framework/core/common/common.go b/pkg/framework/core/common/common.go index 2a5951c..9adf8c7 100644 --- a/pkg/framework/core/common/common.go +++ b/pkg/framework/core/common/common.go @@ -218,6 +218,13 @@ func (c *Common) FailNow() { r.Status = allure.Failed } }) + + if c.xSkip { + c.registerError("[XSkip] test marked as xskip but failed") + c.TestingT.Skip() + return + } + c.TestingT.FailNow() } @@ -235,6 +242,12 @@ func (c *Common) BrokenNow() { r.Status = allure.Broken }) + if c.xSkip { + c.registerError("[XSkip] test marked as xskip but broken") + c.TestingT.Skip() + return + } + c.TestingT.FailNow() }