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

Отображается только один кейс в Allure репорте при использовании тегов сборки #69

Open
7isenko opened this issue Jan 17, 2025 · 1 comment

Comments

@7isenko
Copy link

7isenko commented Jan 17, 2025

Имеем два файла в директории component
duplicating_test.go

//go:build component

package component

import (
	"github.com/stretchr/testify/require"
	"strconv"
	"testing"
)

func TestGeneral(t *testing.T) {
	t.Run("Example test", func(t *testing.T) {
		cases := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
		for _, c := range cases {
			t.Run("subtest "+strconv.Itoa(c), func(t *testing.T) {
				require.NotZero(t, c)

			})
		}
	})

	t.Run("Example second test", func(t *testing.T) {
		cases := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
		for _, c := range cases {
			t.Run("subtest "+strconv.Itoa(c), func(t *testing.T) {
				require.NotZero(t, c)

			})
		}
	})
}

и файл
duplicating2_test.go

//go:build component

package component

import (
	"github.com/stretchr/testify/require"
	"strconv"
	"testing"
)
// Должен быть всегда красный
func TestGeneralSecondTime(t *testing.T) {
	t.Run("Second example test", func(t *testing.T) {
		cases := []int{10, 20, 30, 40, 50, 0}
		for _, c := range cases {
			t.Run("second subtest "+strconv.Itoa(c), func(t *testing.T) {
				require.NotZero(t, c)
			})
		}
	})

	t.Run("Second example second test", func(t *testing.T) {
		cases := []int{10, 20, 30, 40, 50, 0}
		for _, c := range cases {
			t.Run("second subtest "+strconv.Itoa(c), func(t *testing.T) {
				require.NotZero(t, c)
			})
		}
	})
}

Оба помечены тегом //go:build component

Захожу в директорию, запускаю тесты и создаю аллюр отчет следующей командой:
go test -json -tags=component . |golurectl -l -e -s -o ./allure-results --allure-suite TestsWithTag (с указанием -tags=component) и получаю следующий аллюр отчет:
image
Видно, что в сюьте один тест кейс.

image image Второй тест попал в рераны. **По какой-то причине testCaseId обоих тесткейсов равняется md5 от пустой строки.**

У меня получилось решить эту проблему, выйдя из директории и запуская тесты с дополнительным ключом --gotags=component: go test -json -tags=component ./component/... |golurectl -l -e -s -a -o ./allure-results --allure-suite TestsWithTag --gotags component
image
Получаю ожидаемый отчет.

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

@7isenko
Copy link
Author

7isenko commented Jan 17, 2025

Поресерчил еще, запуск прямо из директории, где тесты лежат, отрабатывает криво даже если тегов нет.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant