GithubHelp home page GithubHelp logo

ozontech / allure-go Goto Github PK

View Code? Open in Web Editor NEW
294.0 8.0 33.0 1.97 MB

Complete Allure provider in Go which doesn't overload the interface usage

Home Page: https://t.me/allure_go_chat

License: Apache License 2.0

Makefile 1.26% Go 98.74%
go testing golang allure allure-framework qaautomation qatools qa reporting reporting-tool

allure-go's People

Contributors

dkx86 avatar dskonev-ozon avatar homiache avatar koodeex avatar mirecl avatar moeryomenko avatar nejtr0n avatar nugolnikova avatar ramilkhaybulin avatar siller174 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

allure-go's Issues

Provide context in Before/After methods and test cases

Is your feature request related to a problem? Please describe.
Some tests needs to bypass data between BeforeEach and Test case method.
For example we start appliction on random port in BeforeEach test case and we need that port
in test case to connect application.

Describe the solution you'd like
Common patter to pass data in go is context.Context.

Describe alternatives you've considered
Alternatively we could make getter to test parameters and pass data in it

Documentation mistakes in examples for the suite configuration

There are few documentation mistakes in this example for the suite configuration:

package suite_demo

import (
	"testing"

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

type DemoSuite struct {
	suite.Suite
}

func (s *DemoSuite) TestSkip(t provider.T) {
	t.Epic("Demo")
	t.Feature("Suites")
	t.Title("My first test")
	t.Description(`
		This test will be attached to the suite DemoSuite`)
}

func TestSkipDemo(t *testing.T) {
	t.Parallel()
	runner.RunSuite(t, new(SkipDemoSuite))
}

Seems the TestSkipDemo function should be like that:

func TestSkipDemo(t *testing.T) {
	t.Parallel()
	suite.RunSuite(t, new(DemoSuite))
}
  • new(DemoSuite) instead of the new(SkipDemoSuite) cause the SkipDemoSuite struc doesn't exist in the example.
  • suite.RunSuite instead of the runner.RunSuite cause no any RunSuite method for the runner

Additional info

Just a picture with the current code example:

image

Run test failed with error: Failed marshal Result

Describe the bug
Run test fails with error message like:
Failed marshal Result: json: error calling MarshalJSON for type json.RawMessage: invalid character 'c' after top-level value
Failed marshal Result: json: error calling MarshalJSON for type json.RawMessage: invalid character 'i' after top-level value

To Reproduce
Error appears in github.com/ozontech/allure-go/pkg/[email protected]/container.go
func printContainer()

go.mod
github.com/ozontech/allure-go/pkg/framework v0.6.26
github.com/ozontech/allure-go/pkg/allure v0.6.10

go.sum
github.com/ozontech/allure-go/pkg/allure v0.6.10 h1:chHzORobuPf3UJz23c2n3PIy6QaoxnLgaei2pwBiVxY=
github.com/ozontech/allure-go/pkg/allure v0.6.10/go.mod h1:4oEG2yq+DGOzJS/ZjPc87C/mx3tAnlYpYonk77Ru/vQ=
github.com/ozontech/allure-go/pkg/framework v0.6.26 h1:sHOBTQG5LFQhLFeaAi1zAI9fCSc/L0AbCweO+fgaNOQ=
github.com/ozontech/allure-go/pkg/framework v0.6.26/go.mod h1:iMUFp2UHRFtEGiVajXGVGavlSurfrSfYe9fmutgbvmI=

Expected behavior
Test runs without fails

Снимок экрана 2023-07-17 в 20 36 14

Allure report's FullName duplicates testname for non-suite tests

Describe the bug
Allure report's FullName duplicates testname for non-suite tests

To Reproduce
Steps to reproduce the behavior:

  1. run test with runner.Run(...)
  2. Check report
  3. What has been expected: testRunner/test
  4. What you got actual: testRunner/test/test

Screenshots

Снимок экрана 2022-08-15 в 22 08 25

Error is not included in the allure report if it is in the BeforeAll hook.

Describe the bug
If during the initialization of the suite you add a step with a check that will fall, the entire suite in the allure report is simply ignored. The information in the console is displayed correctly

To Reproduce

import (
	"testing"

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

type BeforeAfterDemoSuite struct {
	suite.Suite
}

func (s *BeforeAfterDemoSuite) BeforeAll(t provider.T) {
	t.WithNewStep("Before suite Step", func(sCtx provider.StepCtx) {
		sCtx.Require().Equal(1, 2, "lol")
	})
}

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.`)

	t.Tags("BeforeAfter")
}

func TestBeforesAfters(t *testing.T) {
	t.Parallel()
	suite.RunSuite(t, new(BeforeAfterDemoSuite))
}

Expected behavior
Display the suite in the report, with an error in the setup and a skipped body of tests.

Странная работа метода t.WithNewStep, t.Step

Добрый день

Сегодня попробовал использовать ваш проект для написания unit тестов, в результате проб возник следующий вопрос: если я в тесте делаю Step (через WithNewStep) и в переданной функции тест фейлится (require не проходит), то в allure отчете все равно данный шаг помечается как успешный. Пример кода, и отчета прилагаю:

type SomeSuite struct {
	suite.Suite
}

func (s *SomeSuite) TestSome(t provider.T) {
	t.WithNewStep("Step 1", func(sCtx provider.StepCtx) {
		require.Equal(t, 2, 2)
	})
	t.WithNewStep("Шаг 2", func(sCtx provider.StepCtx) {
		require.Equal(t, 2, 3)
	})
	t.WithNewStep("Шаг 3", func(sCtx provider.StepCtx) {
		require.Equal(t, 2, 2)
	})

}

func TestSkipDemo(t *testing.T) {
	suite.RunSuite(t, new(SomeSuite))
}

Аналогично если делать t.Step.

133a9d3f-db0d-11ec-9001-bce92f7d8cfc-result.zip

Подскажите, это ожидаемое поведение, или же нет?

Run configuration for GoLand

Is your feature request related to a problem? Please describe.
Ability to run tests with specific run configuration in GoLand ( as discussed in #48 )

Describe the solution you'd like
New run configuration provided by plugin for GoLand

Фильтрация тестов в go

Добрый день,
Настраиваем у себя тестопс в связке с go и gitlab, столкнулись с такой проблемой что не работает фильтрация тестов при запуске.
Наш пайплайн:

stages:
  - test

variables:
  ALLURE_LAUNCH_NAME: "${CI_PROJECT_NAME} - ${CI_COMMIT_SHORT_SHA}"
  ALLURE_LAUNCH_TAGS: "regular, ${CI_COMMIT_REF_NAME}"
  ALLURE_TESTPLAN_PATH: "./testplan.json"
  ALLURE_RESULTS: "allure-results"

test:
  image: golang:latest
  stage: test
  before_script:
    - wget https://github.com/allure-framework/allurectl/releases/latest/download/allurectl_linux_386 -O /usr/bin/allurectl
    - chmod +x /usr/bin/allurectl

    - allurectl job-run start
    - allurectl job-run plan --output-file ${ALLURE_TESTPLAN_PATH}

  script:
    - mkdir -p allure-results
    - allurectl watch --results ${ALLURE_RESULTS} -- go test -v
  after_script:
    - pkill allurectl

При запуске пайплайна есть строки:

$ allurectl job-run plan --output-file ${ALLURE_TESTPLAN_PATH}
Save test plan for [7] to file [/builds/test-framework-allure-testops/testplan.json]
Save test plan for [7] to file [/builds/test-framework-allure-testops/tests/acl]
Running command:  go [test -v]

Из этого сделал вывод что интеграция настроена корректно и проблема непосредственно в allurectl job-run plan --output-file ${ALLURE_TESTPLAN_PATH} что подтвердил Артем Ерошенко

Просьба взять на доработку

SECURITY ERROR: verifying github.com/ozontech/allure-go/pkg/[email protected]: checksum mismatch

Describe the bug
verifying github.com/ozontech/allure-go/pkg/[email protected]: checksum mismatch
downloaded: h1:FVHaO6tkZl1RulL35HZ+M9NlkCtlKpVOR1TSgdEokF4=
go.sum: h1:gSqCHeysGi2+05aeYf02JouLroAB4fQhVkwLTtq1yCY=
SECURITY ERROR
This download does NOT match an earlier download recorded in go.sum.
The bits may have been replaced on the origin server, or an attacker may
have intercepted the download attempt.

To fix:
rm go.sum
go clean -modcache
go mod tidy

Unable to create a tempDir with long test parameters

Describe the bug
Using the new parameterised tests mechanism I'm unable to create a TempDir() if I use relatively long parameter values. The error reported is file name too long

To Reproduce

package example

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

type TestParams struct {
	arg1 string
	arg2 string
	arg3 string
	arg4 string
	arg5 string
	arg6 string
}

type ParametrizedSuite struct {
	suite.Suite
	ParamLongParams []TestParams
}

func (s *ParametrizedSuite) BeforeAll(t provider.T) {
	s.ParamLongParams = []TestParams{
		{
			arg1: "I am a long string used as arg1",
			arg2: "I am a long string used as arg2",
			arg3: "I am a long string used as arg3",
			arg4: "I am a long string used as arg4",
			arg5: "I am a long string used as arg5",
			arg6: "I am a long string used as arg6",
		},
	}
}

func (s *ParametrizedSuite) TableTestLongParams(t provider.T, params TestParams) {
	t.Parallel()
	t.TempDir()
	t.Require().NotEmpty(params)
}

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

Expected behavior
The test name is truncated to create a temp directory.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
output:

/usr/local/go/bin/go tool test2json -t /private/var/folders/_0/4m7k4wy15ygb4wwsj4jbfyc00000gp/T/dlvLauncher2.sh /Users/jaspal.puri/Library/Application Support/JetBrains/Toolbox/apps/Goland/ch-0/223.8214.59/GoLand.app/Contents/plugins/go-plugin/lib/dlv/mac/dlv --listen=127.0.0.1:57440 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /private/var/folders/_0/4m7k4wy15ygb4wwsj4jbfyc00000gp/T/GoLand/___1TestNewParametrizedDemo_in_github_dns_ad_zopa_com_zopaUK_devx_system_tests_system_tests.test -- -test.v -test.paniconexit0 -test.run ^\QTestNewParametrizedDemo\E$
=== RUN   TestNewParametrizedDemo
=== RUN   TestNewParametrizedDemo/ParametrizedSuite
=== RUN   TestNewParametrizedDemo/ParametrizedSuite/BeforeAll
=== RUN   TestNewParametrizedDemo/ParametrizedSuite/Tests
=== RUN   TestNewParametrizedDemo/ParametrizedSuite/Tests/LongParams_{arg1:I_am_a_long_string_used_as_arg1_arg2:I_am_a_long_string_used_as_arg2_arg3:I_am_a_long_string_used_as_arg3_arg4:I_am_a_long_string_used_as_arg4_arg5:I_am_a_long_string_used_as_arg5_arg6:I_am_a_long_string_used_as_arg6}
=== PAUSE TestNewParametrizedDemo/ParametrizedSuite/Tests/LongParams_{arg1:I_am_a_long_string_used_as_arg1_arg2:I_am_a_long_string_used_as_arg2_arg3:I_am_a_long_string_used_as_arg3_arg4:I_am_a_long_string_used_as_arg4_arg5:I_am_a_long_string_used_as_arg5_arg6:I_am_a_long_string_used_as_arg6}
=== CONT  TestNewParametrizedDemo/ParametrizedSuite/Tests/LongParams_{arg1:I_am_a_long_string_used_as_arg1_arg2:I_am_a_long_string_used_as_arg2_arg3:I_am_a_long_string_used_as_arg3_arg4:I_am_a_long_string_used_as_arg4_arg5:I_am_a_long_string_used_as_arg5_arg6:I_am_a_long_string_used_as_arg6}
    test_example_test.go:37: TempDir: mkdir /var/folders/_0/4m7k4wy15ygb4wwsj4jbfyc00000gp/T/TestNewParametrizedDemoParametrizedSuiteTestsLongParams_{arg1I_am_a_long_string_used_as_arg1_arg2I_am_a_long_string_used_as_arg2_arg3I_am_a_long_string_used_as_arg3_arg4I_am_a_long_string_used_as_arg4_arg5I_am_a_long_string_used_as_arg5_arg6I_am_a_long_string_used_as_arg6}51418563: file name too long
--- FAIL: TestNewParametrizedDemo (0.00s)
    --- FAIL: TestNewParametrizedDemo/ParametrizedSuite (0.00s)
        --- PASS: TestNewParametrizedDemo/ParametrizedSuite/BeforeAll (0.00s)
        --- FAIL: TestNewParametrizedDemo/ParametrizedSuite/Tests (0.00s)
            --- FAIL: TestNewParametrizedDemo/ParametrizedSuite/Tests/LongParams_{arg1:I_am_a_long_string_used_as_arg1_arg2:I_am_a_long_string_used_as_arg2_arg3:I_am_a_long_string_used_as_arg3_arg4:I_am_a_long_string_used_as_arg4_arg5:I_am_a_long_string_used_as_arg5_arg6:I_am_a_long_string_used_as_arg6} (0.00s)




FAIL

Debugger finished with the exit code 0```

Request to update Readme.md

Возможно, стоит подсветить обязательность defer перед Teardown и обьяснить почему он нужен, чтобы легче было раскурить этот нюанс без сторонней помощи

Добавить возможность маскировать параметры

Is your feature request related to a problem? Please describe.
Добавить аннотацию для сокрытия чувствительных данных для вложений и отчетов. Под чувствительными данным понимаются пароли, токены, SSL сертификаты и т.д,

Describe the solution you'd like
В задаче allure-framework/allure2#392 была реализована такая возможность в allure-framework. Параметр принимает третий необязательный параметр со скртыми и Исключенными опциями: mode: "hidden" | "masked" - masked скрывает значение параметра, что бы защитить чувствительные данные, и hidden полностью скрывает параметр из отчета

Describe alternatives you've considered
https://www.npmjs.com/package/allure-playwright#parameters-usage

Additional context
В результате должно появиться 2 теста в https://github.com/ozontech/allure-go/blob/master/examples/suite_demo/parameters_test.go

Deadlock in async steps

Describe the bug

  1. WithNewAsyncStep in WithNewAsyncStep will cause deadlock and tests will never finish.

  2. WithNewAsyncStep in step won't be executed async

To Reproduce

  1. example
package my_suite

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

func (s *Suite) TestSome3(t provider.T) {
	t.Parallel()

	t.WithNewStep("sync-step1", func(sCtx provider.StepCtx) {
		sCtx.WithNewAsyncStep("sync-step1-async-step-1", func(sCtx provider.StepCtx) {
			sCtx.WithNewAsyncStep("sync-step1-async-step-1-step1", func(sCtx provider.StepCtx) {
			})
		})
	})
}
package my_suite

import (
	"time"

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

func (s *Suite) TestSome3(t provider.T) {
	t.Parallel()

	startedAt := time.Now()
	timeSinceStart := func() int64 {
		return int64(time.Since(startedAt).Round(time.Second).Seconds())
	}
	sleepDuration := 5 * time.Second

	t.WithNewStep("sync-step1", func(sCtx provider.StepCtx) {
		sCtx.Logf("sync-step1. start: %d", timeSinceStart())
		time.Sleep(sleepDuration)
		sCtx.Logf("sync-step1. finish: %d", timeSinceStart())

		sCtx.WithNewAsyncStep("sync-step1-async-step-1", func(sCtx provider.StepCtx) {
			sCtx.Logf("sync-step1-async-step-1. start: %d", timeSinceStart())
			time.Sleep(sleepDuration)
			sCtx.Logf("sync-step1-async-step-1. finish: %d", timeSinceStart())
		})
		sCtx.WithNewAsyncStep("sync-step1-async-step-2", func(sCtx provider.StepCtx) {
			sCtx.Logf("sync-step1-async-step-2. start: %d", timeSinceStart())
			time.Sleep(sleepDuration)
			sCtx.Logf("sync-step1-async-step-2. finish: %d", timeSinceStart())
		})
	})

	t.WithNewStep("sync-step2", func(sCtx provider.StepCtx) {
		sCtx.Logf("sync-step2. start: %d", timeSinceStart())
		time.Sleep(sleepDuration)
		sCtx.Logf("sync-step2. finish: %d", timeSinceStart())
	})
}

output

    step_context.go:104: sync-step1. finish: 5
    step_context.go:104: sync-step1-async-step-1. start: 5
    step_context.go:104: sync-step1-async-step-1. finish: 10
    step_context.go:104: sync-step1-async-step-2. start: 10
    step_context.go:104: sync-step1-async-step-2. finish: 15
    step_context.go:104: sync-step2. start: 15
    step_context.go:104: sync-step2. finish: 20

Expected behavior

  1. No deadlock
  2. Async steps

Add full support of testing TB inteface

add support of testing.TB

type TB interface {
	Cleanup(func())
	Error(args ...any)
	Errorf(format string, args ...any)
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Helper()
	Log(args ...any)
	Logf(format string, args ...any)
	Name() string
	Setenv(key, value string)
	Skip(args ...any)
	SkipNow()
	Skipf(format string, args ...any)
	Skipped() bool
	TempDir() string
}

Test setup steps logged in Precondition Allure block

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

Create Goland plugin to run tests

Discussed in #48

Originally posted by StasGrishaevTutu January 17, 2023
Привет ! Во-первых, спасибо за проделанную работу, инструмент отличный)
Есть один момент который не даёт покоя, с начала моменты работы с allure-go - это быстрый запуск тестов по клику в GoLand, а именно по зелёнкой иконке play слева :

  • пример с allure-go -
    image
  • пример без allure-go -
    image

те, при использования фреймворка и при условии что тесты наследуются от allureSuite.Suite - запускать можно только целиком сьют, не каждый тест или кейс по отдельности.
скажите, я что то упускаю, как то можно запускать в один клик тесты/кейсы и с использованием allure-go ?

Test falls in afterEach step

Describe the bug
I am running a test in Suite in gitlab. I had an error in test's step with message "index out of range [0]. Allure was logging an error in the afterEach step instead of an error inside test. Moreover, the element I accessed has len = 1, so this shouldn't be an error.

To Reproduce
Steps to reproduce the behavior:

  1. Used func: suite.RunSuite
  2. What you actually wanted to do: to get test passed :)
  3. What has been expected: noError
  4. What you got actual: error in afterEach step
  5. Error Log (if any):
    afterEach panicked: runtime error: index out of range [0] with length 0 goroutine 509 [running]: runtime/debug.Stack() /usr/local/go/src/runtime/debug/stack.go:24 +0x65 github.com/ozontech/allure-go/pkg/framework/runner.(*runner).RunTests.func1.3.1.2() /builds/Nx2CE54f/0/bx/pdp-api/.cache/go/pkg/mod/github.com/ozontech/allure-go/pkg/[email protected]/runner/runner.go:182 +0x85 panic({0x14edf00, 0xc000dbee28}) /usr/local/go/src/runtime/panic.go:884 +0x212 gitlab.*.ru/bx/pdp-api/e2e/internal/steps.(*Helper).GetDigitalBookLitres.func1() /builds/Nx2CE54f/0/bx/pdp-api/e2e/internal/steps/item.go:111 +0x2a5 gitlab.*.ru/marketplace/qa/tools/qa_pack/pkg/utilities.Poll(0x18956c0?, 0xc0004ab6b0?, 0xc000d39198) /builds/Nx2CE54f/0/bx/pdp-api/.cache/go/pkg/mod/gitlab.*.ru/marketplace/qa/tools/[email protected]/pkg/utilities/utilities.go:123 +0xfb gitlab.*.ru/bx/pdp-api/e2e/internal/steps.(*Helper).GetDigitalBookLitres(0xc00040abd0, {0x18956c0, 0xc0004ab6b0}, {0x18acc20, 0xc0000ef7a0}) /builds/Nx2CE54f/0/bx/pdp-api/e2e/internal/steps/item.go:107 +0x176 gitlab.*.ru/bx/pdp-api/e2e/suites.(*WebSmokeSuite).TestWebAddToCartV8wDigitalBook(0xc000072780, {0x18acc20, 0xc0000ef7a0}) /builds/Nx2CE54f/0/bx/pdp-api/e2e/suites/web_suite.go:176 +0x130 reflect.Value.call({0xc000216a20?, 0xc000131830?, 0x30?}, {0x16067f1, 0x4}, {0xc0005a3920, 0x2, 0x18?}) /usr/local/go/src/reflect/value.go:584 +0x8c5 reflect.Value.Call({0xc000216a20?, 0xc000131830?, 0x10?}, {0xc0005a3920?, 0x10?, 0x2561240?}) /usr/local/go/src/reflect/value.go:368 +0xbc github.com/ozontech/allure-go/pkg/framework/runner.(*testMethod).GetBody.func1({0x18acc20?, 0xc0000ef7a0?}) /builds/Nx2CE54f/0/bx/pdp-api/.cache/go/pkg/mod/github.com/ozontech/allure-go/pkg/[email protected]/runner/tests.go:150 +0x2b1 github.com/ozontech/allure-go/pkg/framework/runner.(*runner).RunTests.func1.3.1(0xc000ba9ba0) /builds/Nx2CE54f/0/bx/pdp-api/.cache/go/pkg/mod/github.com/ozontech/allure-go/pkg/[email protected]/runner/runner.go:205 +0x2e7 testing.tRunner(0xc000ba9ba0, 0xc000b8e190) /usr/local/go/src/testing/testing.go:1446 +0x10b created by testing.(*T).Run /usr/local/go/src/testing/testing.go:1493 +0x35f

Expected behavior
If test falls, allure logs error inside test

Incorrect timing of the test

Describe the bug
In allure report every step of the test has execution time, and if we sum every step time, it will not be equal to duration

To Reproduce
Steps to reproduce the behavior:

  1. Run tests with allure-steps

Expected behavior
Summ of the execution time of steps is equal to duration

Screenshots
Снимок экрана 2022-11-22 в 12 20 33

Additional context
As you can see duration != summ of the time of steps

Allure report is not correct in runner execute

Actual result:
Duplication

Expected result:
Should be without duplication

func TestExampleSingleTest_AllureProviderT(t *testing.T) {
    runner.Run(t, "Single test", func(t provider.T) {

    })
}

image

Не запускаются все тесты, при запуске нескольких параметризированных тестов с одинаковыми параметрами

Если запускать несколько параметризированных тестов с одинаковыми параметрами, у них дублируются названия и из-за этого запускается только первый параметризированый тест.

Broken step results in a successful run

Describe the bug
(Probably related to #4)

A single test with a broken step results in a passed test.

The test

func Test_AllureExample(t *testing.T) {
	runner.Run(t, "Allure demo", func(t provider.T) {
		t.WithNewStep("First step", func(sCtx provider.StepCtx) {
			sCtx.Logf("Demo break")
			sCtx.Broken()
		})
	})
}

The report (exluding labels):

{
    "name": "Allure demo",
    "fullName": "Test_AllureExample/Allure_demo",
    "status": "passed",
    "statusDetails": {
        "message": "",
        "trace": ""
    },
    "start": 1669278069758,
    "stop": 1669278069758,
    "uuid": "f34c46a8-6bd0-11ed-bd95-a45e60d5053f",
    "historyId": "baa17e747dc3baf09c0ad0b7a00c6251",
    "testCaseId": "3948cbd85816212b9f92d81b0b03b207",
    "labels": [
    ],
    "steps": [
        {
            "name": "First step",
            "status": "broken",
            "start": 1669278069758,
            "stop": 1669278069758
        }
    ]
}

Note that step has a proper broken status, but the test has a passed status.

A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Create a single test.
  2. Define one step in the test.
  3. use broken() in this step's function.
  4. Check report.

Expected behavior
The test is marked as Broken in the report.

Additional context
I have some questions regarding this issue:

  1. Is it a bug or is it intended? If intended, how can i apple Broken status to a test?
  2. What should be done either way with provider.T of my test after setting some step to broken()? There is no BreakNow() fn, so i just have to end the test execution naturally after a broken step?
  3. Which go test status (skipped / failed) will be applied to the test, if it s properly set as Broken by the library?

Support t.Helper()

  1. Support Helper() in StepCtx

  2. Add t.Helper() to Error() and ErrorF

Test: bla_test.go

func TestName(t *testing.T) {
	runner.Run(t, "Single test with allure-go Runner", func(t provider.T) {
		t.Epic("Compare with allure-go")
		t.Description("New Test Description")
		t.WithNewStep("Step description", func(ctx provider.StepCtx) {
			ctx.Errorf("Error message")
		})
	})
}

func TestName1(t *testing.T) {
	runner.Run(t, "Single test with allure-go Runner", func(t provider.T) {
		t.Errorf("Error message")
	})
}

Logs without helper:

=== RUN   TestName
=== RUN   TestName/Single_test_with_allure-go_Runner
    common.go:125: Error message
--- FAIL: TestName (0.00s)
    --- FAIL: TestName/Single_test_with_allure-go_Runner (0.00s)


=== RUN   TestName1
=== RUN   TestName1/Single_test_with_allure-go_Runner
    common.go:125: Error message
--- FAIL: TestName1 (0.00s)
    --- FAIL: TestName1/Single_test_with_allure-go_Runner (0.00s)

Log with helper:

=== RUN   TestName
=== RUN   TestName/Single_test_with_allure-go_Runner
     bla_test.go:22: Error message  <--- trace from test
--- FAIL: TestName (0.00s)
    --- FAIL: TestName/Single_test_with_allure-go_Runner (0.00s)


=== RUN   TestName1
=== RUN   TestName1/Single_test_with_allure-go_Runner
    bla_test.go:22: Error message <--- trace from test
--- FAIL: TestName1 (0.00s)
    --- FAIL: TestName1/Single_test_with_allure-go_Runner (0.00s)


FAIL

Set up/Tear down sections are not displayed in tests without suite

Describe the bug
Set up/Tear down sections are not displayed in tests without suite

To Reproduce
Steps to reproduce the behavior:
1-2. Write simple test with t.WithTestSetup()/t.WithTestTeardown()

func TestSetupTeardown1(t *testing.T) {
	runner.Run(t, "My 1 test", func(t provider.T) {
		t.WithTestSetup(func(t provider.T) {
			t.WithNewStep("My 1 Step!", func(sCtx provider.StepCtx) {
				time.Sleep(1 * time.Second)
			})
		})
		t.WithNewStep("My 2 Step!", func(sCtx provider.StepCtx) {
			time.Sleep(1 * time.Second)
		})
		t.WithTestTeardown(func(t provider.T) {
			t.WithNewStep("My 3 Step!", func(sCtx provider.StepCtx) {
				time.Sleep(1 * time.Second)
			})
		})
	})
}
  1. What has been expected: 't.WithTestSetup()/t.WithTestTeardown() sections are displayed in allure-report'
  2. What you got actual: 't.WithTestSetup()/t.WithTestTeardown() sections are not displayed in allure-report'
  3. Allure-Report screenshot (if any):
    image

Expected behavior
t.WithTestSetup()/t.WithTestTeardown() sections are displayed in allure-report as in the tests with suites

Screenshots
image

Параметризованным тестам проставляется отдельный Suite (не родительский)

При использовании фичи TableTest такие автотесты в отчете помечаются отдельным, не родительским сьютом.

Воспроизведение:

  • Создать Suite в котором запускается RunSuite
  • Создать функцию BeforeAll в которой создать параметры для теста
  • Написать параметризированный тест
  • Написать обычный тест
  • Запустить тесты

Ожидаемое поведение:
Оба автотеста живут в одном Suite

Фактическое поведение:
Параметризированный тест живет в отдельном Suite (по названию автотеста)

На скриншоте видно что автотест TableTestCRMCreateHireObject не попал в SmokeSuite, а создал новый Suite по названию теста
Screenshot 2022-08-24 at 16 54 05

Add InDelta asserts wrapper

stretchr/testify/assert has assert.InDelta() function, and I use it in my tests. But allure-go hasn't such one. It would be nice to have.

allure-results Not Generated for Linux Debian 11

Describe the bug
After running go test ./..., expected allure-results folder is not generated even both $ALLURE_OUTPUT_PATH and $ALLURE_OUTPUT_FOLDER are set up correctly. It works fine on my Macbook laptop.

To Reproduce
Steps to reproduce the behavior:

  1. Run go test on Debian GNU 11 and no allure-results generated.

Expected behavior
See above description.

Add functions to logging with automatic step creation

Is your feature request related to a problem? Please describe.
Add functions to logging with automatic step creation. It will reduce amount of calls for test describing

Describe the solution you'd like

func TestSome(t provider.T) {
     t.LogStep("Step1")
     t.LogfStep("%s, %s", "arg1", "arg2")
     t.WithNewStep("Step3", func(sCtx provider.StepCtx) {
	sCtx.LogStep("Step3.1")
	sCtx.LogfStep("Step3.2: %s, %s", "arg1", "arg2")
     })
}

Снимок экрана 2022-08-15 в 22 14 10

How to generate Allure-report

I was able to generate the allure results and allure report locally. I am trying to run this command:

allure generate allure-results --clean -o allure-report

and i getting the below error:

$ allure generate allure-results --clean -o allure-report
/scripts-975-835204/step_script: line 181: allure: command not found

Is there an golang version of allure-commandline ?

Add new asserts

Adding new asserts:

  • for matching strings by regexp
  • for checking that one JSON contains another

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.