Skip to content

Release v0.6.16

Compare
Choose a tag to compare
@koodeex koodeex released this 22 Aug 19:43
· 122 commits to master since this release
4be753f

Release Notes:

Features

  • add faker to dependencies (for examples)
  • add table test example
  • Readme updates

pkg/allure (v0.6.3)

Features

  • Add ToJSON() ([]byte, error) method to the Result object. It marshall Result to the JSON and returns error if any.
  • Add ToJSON() ([]byte, error) method to the Container object. It marshall Container to the JSON and returns error if any.
  • Add Done() error method to the Container object. It works same as Result.Done method.
  • Now Result.Done() returns error if any.

pkg/framework (v0.6.16)

Features

Major:

Parametrized tests

Now you can run your parametrized tests in new way at GO

  • ❓ How to use it?
  1. You need extend your suite struct with array of parameters. Its name MUST be like ParamTestNameWithoutPrefix.
    i.e. if your test named like TableTestCities so param should have name ParamCities
  2. You need to create test method that will take your parameter as second argument after provider.T. Test name **
    MUST** have prefix TableTest instead of just Test. i.e. TableTestCities.

Simple example:

package suite_demo

import (
	"testing"

	"github.com/jackc/fake"
	"github.com/ozontech/allure-go/pkg/framework/provider"
	"github.com/ozontech/allure-go/pkg/framework/suite"
)

type ParametrizedSuite struct {
	suite.Suite
	// ParamCities param has name as expected test but has prefix Param instead of TableTest
	ParamCities []string
}

func (s *ParametrizedSuite) BeforeAll(t provider.T) {
	for i := 0; i < 10; i++ {
		s.ParamCities = append(s.ParamCities, fake.City())
	}
}

// TableTestCities is parametrized test has name prefix TableTest instead of Test
func (s *ParametrizedSuite) TableTestCities(t provider.T, city string) {
	t.Parallel()
	t.Require().NotEmpty(city)
}

func TestNewParametrizedDemo(t *testing.T) {
	suite.RunSuite(t, new(ParametrizedSuite))
}

Allure Output:
example_table_test

runner.RunTests and suite.RunSuites ouput:

Now runner.RunTests and suite.RunSuites returns interface SuiteResult. It contains all information about tests that you can use to customize your allure integrations

Minor:

  • reworked test collecting
  • now errors in file creations will be logging as t.Error
  • provider.T.Run now returns allure.Result pointer