ozontech / allure-go

Complete Allure provider in Go which doesn't overload the interface usage
https://t.me/allure_go_chat
Apache License 2.0
317 stars 34 forks source link

Test setup steps logged in Precondition Allure block #30

Closed Gorgy33 closed 2 years ago

Gorgy33 commented 2 years ago

Is your feature request related to a problem? Please describe. Now days all test setup steps logged in test steps block

Describe the solution you'd like I want something like WithTestSetup method in provider.T interface for logging into preconditions block

koodeex commented 2 years ago

Hmm, there is a proposal:

func (s *MySuite) TestSomeTest(t provider.T) {
     var (
         v1 string
         v2 int
         ctx context.Context
     )
     t.WithTestSetup(func (t provider.T) {
            // all here will be in Set up section in allure report
            t.WithNewStep("Init v1", func(sCtx, StepCtx) {
                  v1 = "SomeString"
                  sCtx.WithParams("v1", v1)
            }
            t.WithNewStep("Init v2", func(sCtx, StepCtx) {
                  v2 = 123
                  sCtx.WithParams("v2", v2)
            }
             t.WithNewStep("Init ctx", func(sCtx, StepCtx) {
                  ctx = context.Background()
                  sCtx.WithParams("ctx", ctx)
            }
     })
     defer t.WithTestTearDown(func (t provider.T) {
            // all here will be in Tear down section in allure report
            t.WithNewStep("close ctx", func(sCtx, StepCtx) {
                  ctx.Done()
                  sCtx.WithParams("ctx", ctx)
            }
     })
     // ...
}