Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release060 #10

Merged
merged 63 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7e8982a
[060] test collection reworked. hooks work reworked TODO: fix async
Jun 1, 2022
2df5e90
[060] fix version
Jun 1, 2022
fa2b427
[060] fix async. TODO: fix AfterAll
Jun 1, 2022
91a8b73
[060] fixed all async hooks
Jun 1, 2022
5ef3129
[060] remove commented code
Jun 1, 2022
3394f51
[060] remove commented code
Jun 1, 2022
babf227
[060] update testify version
Jun 1, 2022
4bed8fa
[060] update allure version to v0.6.0
Jun 1, 2022
13ec291
[060] lint fixes
Jun 1, 2022
ca2b875
[060] dependencies update
Jun 1, 2022
e955b37
[060] test plan fix
Jun 2, 2022
5652bde
[061] update framework version
Jun 2, 2022
2f1e5ac
[062] fix test plan filter
Jun 2, 2022
1784686
[062] update version
Jun 2, 2022
7208d18
[063] fix of id type
Jun 2, 2022
4483031
[063] update framework version
Jun 2, 2022
719a490
[064] fix npe with TestPlan
Jun 2, 2022
f4d1662
[065] fix Suite Tests filtering with TestPlan
Jun 2, 2022
f7c722c
[065] update framework version
Jun 2, 2022
8bd727d
[066] hard parallel fix
Jun 3, 2022
15392e9
[066] fix package naming for internal suites
Jun 3, 2022
44700d5
[066] GetTestPlan() now calls only once
Jun 3, 2022
90b7e19
[066] update framework version
Jun 3, 2022
44fb09e
[v067] add windows support for make demo
koodeex Jun 6, 2022
c1ff844
[v067] add windows and linux support for make install
koodeex Jun 6, 2022
09b909e
[v067] add exit suite run if no tests in filter
koodeex Jun 6, 2022
2b8e090
[v067] fix relative path support for test plan feature
koodeex Jun 6, 2022
b2d8b9b
[v068] fix relative path support for test plan feature
koodeex Jun 8, 2022
de7b6b1
[v069] fix relative path support for test plan feature
koodeex Jun 8, 2022
72f49e4
[v068] fix relative path support for test plan feature
koodeex Jun 8, 2022
e14ff69
[0610] fix tests and suites naming
Jul 4, 2022
95a560c
[0610] add TB.Fatal and TB.Fatalf support
Jul 4, 2022
5832f20
[0610] add mixed async example
Jul 4, 2022
059f428
[0610] update framework version
Jul 4, 2022
9a6ebb1
[0611] fix lint and tests
Jul 4, 2022
6baaa2d
[0611] fix lint
Jul 4, 2022
29214d2
[0611] fix make run (now make examples always return true)
Jul 4, 2022
374c1cd
[0611] create README_new.md
Jul 4, 2022
18bce53
[0611] add examples
Jul 4, 2022
dd49f0c
[0611] remove README_old.md
Jul 4, 2022
d203d85
[0611] README.md update
Jul 4, 2022
2503e63
[0611] README.md update
Jul 4, 2022
d7c914d
[0611] add Name, Fail, FailNow and Skipf support due [ISSUE-11]
Jul 4, 2022
15b273e
[0611] Name() fix
Jul 4, 2022
e3a2a01
[0611] naming fix
Jul 4, 2022
22d0642
[0611] StepCtx failNow will fail step now before finishing.
Jul 5, 2022
a1ffed4
[0611] README.md update
Jul 5, 2022
7c3f6dc
[0611] README.md update
Jul 5, 2022
a265406
[0611] README.md update
Jul 5, 2022
021b929
[0611] README.md update
Jul 5, 2022
32d526d
[0611] README.md update
Jul 5, 2022
306a2ac
[0611] README.md update
Jul 5, 2022
1d63799
[0611] README.md update
Jul 5, 2022
5d62e6d
[0611] Now testplan will notify if it will found testplan.json (inste…
Jul 6, 2022
38e9b65
[0611] Fixed tagging in mixed_test example
Jul 6, 2022
6c9f6b9
[0611] Fixed update README.md and description of some comments
Jul 6, 2022
94141f3
[0611] add async test example
Jul 6, 2022
84b77e5
[0611] BeforeAll panic case fix
Jul 6, 2022
01879b3
[0611] Commented line remove
Jul 6, 2022
b5db445
Merge branch 'master' into release060
Jul 6, 2022
114eada
[0611] allure version update
Jul 6, 2022
906af99
[0611] remove examples lint
Jul 6, 2022
674b1c0
[0611] update dependencies
Jul 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP?=allure-go
RELEASE?=0.5.8
RELEASE?=0.6.0
GOOS?=darwin

COMMIT?=$(shell git rev-parse --short HEAD)
Expand All @@ -8,6 +8,7 @@ BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
export GO111MODULE=on
export GOSUMDB=off
LOCAL_BIN:=$(CURDIR)/bin
EXAMPLES_TAGS:=examples_new,provider_new,allure_go_new,async

##################### GOLANG-CI RELATED CHECKS #####################
# Check global GOLANGCI-LINT
Expand Down Expand Up @@ -48,12 +49,41 @@ full-demo: install demo
demo: examples allure-serve

.PHONY: install
install:
go mod tidy && go mod download && brew install allure
install: .install_deps .install_allure

.PHONY: .install_deps
.install_deps:
go mod tidy && go mod download

.PHONY: .install_allure
.install_allure:
ifeq ($(OS),Windows_NT)
$(info Run Windows run pattern...)
$(info Make sure scoop installed at your system. Check for more information: https://github.com/ScoopInstaller/Scoop#installation)
scoop install allure
endif
ifeq ($(OS),Linux)
$(info Run Linux run pattern...)
$(info Make sure you have sudo rights for the system.)
sudo apt-add-repository ppa:qameta/allure
sudo apt-get update
sudo apt-get install allure
endif
ifeq ($(OS),Darwin)
$(info Run installation for Darwin OS)
$(info Make sure brew installed at your system. Check for more information: https://docs.brew.sh/Installation)
brew install allure
endif

.PHONY: examples
examples:
- export ALLURE_OUTPUT_PATH=../ && go test ./examples/... --tags=examples_new,provider_new,allure_go_new,async
ifeq ($(OS),Windows_NT)
$(info Run windows pattern...)
set ALLURE_OUTPUT_PATH=../&& go test ./examples/... --tags=$(EXAMPLES_TAGS)
else
$(info Run default pattern...)
export ALLURE_OUTPUT_PATH=../ && go test ./examples/... --tags=$(EXAMPLES_TAGS)
endif

.PHONY: allure-serve
allure-serve:
Expand All @@ -62,8 +92,7 @@ allure-serve:
# run full lint like in pipeline
.PHONY: lint
lint: install-lint
$(GOLANGCI_BIN) run --config=.golangci.yaml ./... --build-tags=examples_new,provider_new,allure_go_new,async

$(GOLANGCI_BIN) run --config=.golangci.yaml ./... --build-tags=$(EXAMPLES_TAGS)

.PHONY: install-lint
install-lint:
Expand Down
2 changes: 1 addition & 1 deletion examples/async/async_step_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (s *StepAsyncDemo) TestAsyncStepDemo6(t provider.T) {
}

func (s *StepAsyncDemo) TestAsyncStepDemo7(t provider.T) {
t.Title("Test with async steps ")
t.Title("Test with async steps 7")

t.WithNewAsyncStep("Async Step 1", func(ctx provider.StepCtx) {
ctx.WithNewParameters("Start", fmt.Sprintf("%s", time.Now()))
Expand Down
3 changes: 2 additions & 1 deletion examples/suite_demo/befores_afters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ func (s *BeforeAfterDemoSuite) BeforeAll(t provider.T) {

func (s *BeforeAfterDemoSuite) AfterAll(t provider.T) {
t.NewStep("After suite Step")
t.Logf("HI")
}

func (s *BeforeAfterDemoSuite) TestBeforeAfterTest(t provider.T) {
t.Epic("Demo")
t.Feature("BeforeAfter")
t.Title("Test wrapped with SetUp & TearDown")
t.Description(`
This test wrapped with SetUp and TearDown containert.`)
This test wrapped with SetUp and TearDown container.`)

t.Tags("BeforeAfter")
}
Expand Down
4 changes: 2 additions & 2 deletions examples/suite_demo/running_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package suite_demo

import (
"github.com/ozontech/allure-go/pkg/framework/provider"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go fmt

"testing"

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

Expand All @@ -31,7 +31,7 @@ func (s *TestRunningDemoSuite) TestLabels(t provider.T) {
}

func TestRunDemo(t *testing.T) {
// use RunSuites to run suite of suites
// use RunSuite to run suite of suites
t.Parallel()
suite.RunSuite(t, new(TestRunningDemoSuite))
}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ replace (
)

require (
github.com/ozontech/allure-go/pkg/allure v0.5.6
github.com/ozontech/allure-go/pkg/framework v0.5.8
github.com/ozontech/allure-go/pkg/allure v0.6.0
github.com/ozontech/allure-go/pkg/framework v0.6.6
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.7.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions pkg/allure/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package allure

const (
// DefaultVersion - allure-testify current Version
DefaultVersion = "Allure-Testify@v0.5.0"
// DefaultVersion - allure-go current Version
DefaultVersion = "Allure-Go@v0.6.0"

resultsPathEnvKey = "ALLURE_OUTPUT_PATH" // Indicates the path to the results print folder
outputFolderEnvKey = "ALLURE_OUTPUT_FOLDER" // Indicates the name of the folder to print the results.
Expand Down
7 changes: 4 additions & 3 deletions pkg/allure/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ go 1.17
require (
github.com/google/uuid v1.3.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.7.1
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
github.com/stretchr/objx v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)
9 changes: 9 additions & 0 deletions pkg/allure/go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1 change: 0 additions & 1 deletion pkg/framework/core/allure_manager/adapter/test_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,4 @@ func (ctx *TestAdapter) SetAfterEach(hook func(provider.T)) {
// GetAfterEach returns after each function
func (ctx *TestAdapter) GetAfterEach() func(provider.T) {
return ctx.afterEach

}
4 changes: 4 additions & 0 deletions pkg/framework/core/allure_manager/manager/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func (a *allureManager) GetResult() *allure.Result {
return a.testMeta.GetResult()
}

func (a *allureManager) SetTestMeta(meta provider.TestMeta) {
a.testMeta = meta
}

func (a *allureManager) GetTestMeta() provider.TestMeta {
return a.testMeta
}
Expand Down
130 changes: 130 additions & 0 deletions pkg/framework/core/allure_manager/testplan/testplan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package testplan

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"sync"
)

var (
once = sync.Once{}
testPlan = initTestPlan()
)

// Path to testplan.json
const testPlanPath = "ALLURE_TESTPLAN_PATH"
koodeex marked this conversation as resolved.
Show resolved Hide resolved

type TestCase struct {
ID int `json:"id"`
Selector string `json:"selector"`
}

type TestPlan struct {
Version string `json:"version"`
Tests []*TestCase `json:"tests"`
}

func newTestPlan() (*TestPlan, error) {
koodeex marked this conversation as resolved.
Show resolved Hide resolved
filePath := os.Getenv(testPlanPath)
if filePath == "" {
return nil, fmt.Errorf("{%s} environment variable not set", testPlanPath)
}
if !strings.HasSuffix(filePath, ".json") {
return nil, fmt.Errorf("%s environment variable has a wrong format. Please, set path to .json file. Current path:%s", testPlanPath, filePath)
}

testPlanRaw, readFileErr := findTestPlan(filePath)
if readFileErr != nil {
return nil, readFileErr
}

plan := &TestPlan{}
err := json.Unmarshal(testPlanRaw, plan)
if err != nil {
return nil, err
}

if plan != nil && len(plan.Tests) == 0 {
return nil, fmt.Errorf("no any tests found in %s", filePath)
}
return plan, nil
}

// IsSelected returns true if selector matches with testplan selector
// TODO: ID parsing from TestOps
func (p *TestPlan) IsSelected(id, selector string) bool {
for _, t := range p.Tests {
if t.Selector == selector {
return true
}
}
return false
}

func initTestPlan() *TestPlan {
var (
err error
tPlan *TestPlan
)

testPlanOnce := func() {
tPlan, err = newTestPlan()
if err != nil {
fmt.Printf("%s\n", err.Error())
}
}
once.Do(testPlanOnce)
return tPlan
}

// GetTestPlan ...
func GetTestPlan() *TestPlan {
return testPlan
}

func findTestPlan(path string) (testPlanRaw []byte, readFileErr error) {
testPlanRaw, readFileErr = ioutil.ReadFile(filepath.Clean(path))
if readFileErr == nil && testPlanRaw != nil {
return testPlanRaw, nil
}
dir, getWdErr := os.Getwd()
if getWdErr != nil {
return nil, getWdErr
}

pathParts := strings.Split(dir, string(os.PathSeparator))

// windows absolute path workaround
// issue describing: https://github.com/golang/go/issues/26953#issuecomment-412447719
if strings.HasSuffix(pathParts[0], ":") {
pathParts[0] = pathParts[0] + "/"
}

// os.Getwd() returns current test folder.
// trying to walk up the absolute path to find testplan.json
tmpPathParts := pathParts
for _, _ = range pathParts {
basicPath := filepath.Join(tmpPathParts...)
absolutePath := filepath.Join(basicPath, filepath.Clean(path))
if pathParts[0] == "" && len(pathParts) > 1 {
absolutePath = "/" + absolutePath
}

testPlanRaw, readFileErr = ioutil.ReadFile(absolutePath)
if readFileErr != nil {
// stop looking if project root found
_, gErr := ioutil.ReadFile(filepath.Join(basicPath, "go.mod"))
if gErr == nil {
return
}
tmpPathParts = tmpPathParts[:len(tmpPathParts)-1]
continue
}
break
}
return
}
Loading