How to use TestSuiteTests method of internal_integration_test Package

Best Ginkgo code snippet using internal_integration_test.TestSuiteTests

Run Ginkgo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

internal_integration_suite_test.go

Source: internal_integration_suite_test.go Github

copy
1package internal_integration_test
2
3import (
4	"io"
5	"reflect"
6	"testing"
7
8	. "github.com/onsi/ginkgo/v2"
9	"github.com/onsi/ginkgo/v2/internal"
10	"github.com/onsi/ginkgo/v2/internal/global"
11	"github.com/onsi/ginkgo/v2/internal/parallel_support"
12	. "github.com/onsi/ginkgo/v2/internal/test_helpers"
13	"github.com/onsi/ginkgo/v2/types"
14	. "github.com/onsi/gomega"
15)
16
17func TestSuiteTests(t *testing.T) {
18	RegisterFailHandler(Fail)
19	RunSpecs(t, "Suite Integration Tests")
20}
21
22var conf types.SuiteConfig
23var failer *internal.Failer
24var writer *internal.Writer
25var reporter *FakeReporter
26var rt *RunTracker
27var cl types.CodeLocation
28var interruptHandler *FakeInterruptHandler
29var outputInterceptor *FakeOutputInterceptor
30
31var server parallel_support.Server
32var client parallel_support.Client
33var exitChannels map[int]chan interface{}
34
35var _ = BeforeEach(func() {
36	conf = types.SuiteConfig{}
37	failer = internal.NewFailer()
38	writer = internal.NewWriter(io.Discard)
39	writer.SetMode(internal.WriterModeBufferOnly)
40	reporter = &FakeReporter{}
41	rt = NewRunTracker()
42	cl = types.NewCodeLocation(0)
43	interruptHandler = NewFakeInterruptHandler()
44	DeferCleanup(interruptHandler.Stop)
45
46	outputInterceptor = NewFakeOutputInterceptor()
47
48	conf.ParallelTotal = 1
49	conf.ParallelProcess = 1
50	conf.RandomSeed = 17
51
52	server, client, exitChannels = nil, nil, nil
53})
54
55/* Helpers to set up and run test fixtures using the Ginkgo DSL */
56func WithSuite(suite *internal.Suite, callback func()) {
57	originalSuite, originalFailer := global.Suite, global.Failer
58	global.Suite = suite
59	global.Failer = failer
60	callback()
61	global.Suite = originalSuite
62	global.Failer = originalFailer
63}
64
65func SetUpForParallel(parallelTotal int) {
66	conf.ParallelTotal = parallelTotal
67	server, client, exitChannels = SetUpServerAndClient(conf.ParallelTotal)
68	conf.ParallelHost = server.Address()
69}
70
71func RunFixture(description string, callback func()) (bool, bool) {
72	suite := internal.NewSuite()
73	var success, hasProgrammaticFocus bool
74	WithSuite(suite, func() {
75		callback()
76		Ω(suite.BuildTree()).Should(Succeed())
77		success, hasProgrammaticFocus = suite.Run(description, Label("TopLevelLabel"), "/path/to/suite", failer, reporter, writer, outputInterceptor, interruptHandler, client, conf)
78	})
79	return success, hasProgrammaticFocus
80}
81
82func F(options ...interface{}) {
83	location := cl
84	message := "fail"
85	for _, option := range options {
86		if reflect.TypeOf(option).Kind() == reflect.String {
87			message = option.(string)
88		} else if reflect.TypeOf(option) == reflect.TypeOf(cl) {
89			location = option.(types.CodeLocation)
90		}
91	}
92
93	failer.Fail(message, location)
94	panic("panic to simulate how ginkgo's Fail works")
95}
96
97func Abort(options ...interface{}) {
98	location := cl
99	message := "abort"
100	for _, option := range options {
101		if reflect.TypeOf(option).Kind() == reflect.String {
102			message = option.(string)
103		} else if reflect.TypeOf(option) == reflect.TypeOf(cl) {
104			location = option.(types.CodeLocation)
105		}
106	}
107
108	failer.AbortSuite(message, location)
109	panic("panic to simulate how ginkgo's AbortSuite works")
110}
111
112func FixtureSkip(options ...interface{}) {
113	location := cl
114	message := "skip"
115	for _, option := range options {
116		if reflect.TypeOf(option).Kind() == reflect.String {
117			message = option.(string)
118		} else if reflect.TypeOf(option) == reflect.TypeOf(cl) {
119			location = option.(types.CodeLocation)
120		}
121	}
122
123	failer.Skip(message, location)
124	panic("panic to simulate how ginkgo's Skip works")
125}
126
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger TestSuiteTests code on LambdaTest Cloud Grid

Execute automation tests with TestSuiteTests on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)