diff --git a/README.md b/README.md index 00901ac..6f71721 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The project started as a fork of testify, but over time it got its own runner an + [XSkip](#xskip) + [:rocket: Parametrized tests](#parametrized-test) + [Setup test](#setup-test) + + [Prevent loosing allureID in test results](#Prevent-loosing-allureID-in-test-results) ## :zap: Features @@ -806,13 +807,13 @@ Allure output: ![](.resources/example_setup_test.png) -### Prevent loosing allureId in test results +### Prevent loosing allureID in test results -When suit fails at the setup stage (beforeAll), report will not contain `allureId` field. -To prevent it you can use `GetAllureId(testName string) string` method for common tests and +When suit fails at the setup stage (beforeAll), report will not contain `ALLURE_ID` field. +To prevent it you can use `GetAllureID(testName string) string` method for common tests and `InitializeTestsParams()` method for parametrized tests. -**Example for `GetAllureId` method:** +**Example for `GetAllureID` method:** ```go package suite_demo @@ -824,11 +825,11 @@ import ( "github.com/ozontech/allure-go/pkg/framework/suite" ) -type AllureIdSuite struct { +type AllureIDSuite struct { suite.Suite } -func (testSuit *AllureIdSuite) GetAllureId(testName string) string { +func (testSuit *AllureIDSuite) GetAllureID(testName string) string { switch testName { case "TestWithAllureIDFirst": return "9001" @@ -839,20 +840,20 @@ func (testSuit *AllureIdSuite) GetAllureId(testName string) string { } } -func (s *AllureIdSuite) BeforeAll(t provider.T) { +func (s *AllureIDSuite) BeforeAll(t provider.T) { // code that can fail here } -func (s *AllureIdSuite) TestWithAllureIDFirst(t provider.T) { +func (s *AllureIDSuite) TestWithAllureIDFirst(t provider.T) { // code of your test here } -func (s *AllureIdSuite) TestWithAllureIDSecond(t provider.T) { +func (s *AllureIDSuite) TestWithAllureIDSecond(t provider.T) { // code of your test here } func TestNewDemo(t *testing.T) { - suite.RunSuite(t, new(AllureIdSuite)) + suite.RunSuite(t, new(AllureIDSuite)) } ``` @@ -871,13 +872,13 @@ import ( ) type CitiesParam struct { - allureId string + allureID string title string value string } -func (p CitiesParam) GetAllureId() string { - return p.allureId +func (p CitiesParam) GetAllureID() string { + return p.allureID } func (p CitiesParam) GetAllureTitle() string { return p.title @@ -892,13 +893,13 @@ func (s *ParametrizedSuite) InitializeTestsParams() { s.ParamCities = make([]CitiesParam, 2) s.ParamCities[0] = CitiesParam{ title: "Title for city test #1", - allureId: "101", + allureID: "101", value: fake.City(), } s.ParamCities[1] = CitiesParam{ title: "Title for city test #2", - allureId: "102", + allureID: "102", value: fake.City(), } } diff --git a/pkg/framework/runner/interfaces.go b/pkg/framework/runner/interfaces.go index fb63fc9..41eda2d 100644 --- a/pkg/framework/runner/interfaces.go +++ b/pkg/framework/runner/interfaces.go @@ -32,10 +32,10 @@ type AllureAfterSuite interface { AfterAll(t provider.T) } -// AllureIdSuite has a GetAllureId method, -// which will produce allureIds for the test by its name -type AllureIdSuite interface { - GetAllureId(testName string) string +// AllureIDSuite has a GetAllureID method, +// which will produce allureIDs for the test by its name +type AllureIDSuite interface { + GetAllureID(testName string) string } // ParametrizedSuite suit can initialize parameters for @@ -47,7 +47,7 @@ type ParametrizedSuite interface { // ParametrizedTestParam parameter for parametrized test // with custom AllureId and Title type ParametrizedTestParam interface { - GetAllureId() string + GetAllureID() string GetAllureTitle() string } diff --git a/pkg/framework/runner/suite_runner.go b/pkg/framework/runner/suite_runner.go index 2342bc4..55cb153 100644 --- a/pkg/framework/runner/suite_runner.go +++ b/pkg/framework/runner/suite_runner.go @@ -76,11 +76,11 @@ func collectTests(runner *suiteRunner, tSuite TestSuite) { packageName = runner.packageName suiteName = runner.internalT.GetProvider().GetSuiteMeta().GetSuiteName() suiteFullName = runner.internalT.GetProvider().GetSuiteMeta().GetSuiteFullName() - getAllureId func(string) string + getAllureID func(string) string ) - if ais, ok := tSuite.(AllureIdSuite); ok { - getAllureId = ais.GetAllureId + if ais, ok := tSuite.(AllureIDSuite); ok { + getAllureID = ais.GetAllureID } for i := 0; i < methodFinder.NumMethod(); i++ { @@ -97,8 +97,8 @@ func collectTests(runner *suiteRunner, tSuite TestSuite) { testMeta := adapter.NewTestMeta(suiteFullName, suiteName, method.Name, packageName) - if getAllureId != nil { - id := getAllureId(method.Name) + if getAllureID != nil { + id := getAllureID(method.Name) if len(id) > 0 { testMeta.GetResult().AddLabel(allure.IDAllureLabel(id)) } @@ -196,7 +196,7 @@ func getParamTests(parentTest Test, params map[string]interface{}) map[string]Te if ptp, ok := param.(ParametrizedTestParam); ok { meta.GetResult().Name = ptp.GetAllureTitle() - meta.GetResult().AddLabel(allure.IDAllureLabel(ptp.GetAllureId())) + meta.GetResult().AddLabel(allure.IDAllureLabel(ptp.GetAllureID())) } res[pName] = &testMethod{