How to use SuiteWillBegin method of test_helpers Package

Best Ginkgo code snippet using test_helpers.SuiteWillBegin

Run Ginkgo automation tests on LambdaTest cloud grid

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

client_server_test.go

Source: client_server_test.go Github

copy
1package parallel_support_test
2
3import (
4	"fmt"
5	"os"
6	"time"
7
8	. "github.com/onsi/ginkgo/v2"
9	. "github.com/onsi/gomega"
10	"github.com/onsi/gomega/gbytes"
11
12	"github.com/onsi/ginkgo/v2/internal"
13	"github.com/onsi/ginkgo/v2/internal/parallel_support"
14	. "github.com/onsi/ginkgo/v2/internal/test_helpers"
15	"github.com/onsi/ginkgo/v2/types"
16)
17
18type ColorableStringerStruct struct {
19	Label string
20	Count int
21}
22
23func (s ColorableStringerStruct) String() string {
24	return fmt.Sprintf("%s %d", s.Label, s.Count)
25}
26
27func (s ColorableStringerStruct) ColorableString() string {
28	return fmt.Sprintf("{{red}}%s {{green}}%d{{/}}", s.Label, s.Count)
29}
30
31var _ = Describe("The Parallel Support Client & Server", func() {
32	for _, protocol := range []string{"RPC", "HTTP"} {
33		protocol := protocol
34		Describe(fmt.Sprintf("The %s protocol", protocol), Label(protocol), func() {
35			var (
36				server   parallel_support.Server
37				client   parallel_support.Client
38				reporter *FakeReporter
39				buffer   *gbytes.Buffer
40			)
41
42			BeforeEach(func() {
43				GinkgoT().Setenv("GINKGO_PARALLEL_PROTOCOL", protocol)
44
45				var err error
46				reporter = &FakeReporter{}
47				server, err = parallel_support.NewServer(3, reporter)
48				Ω(err).ShouldNot(HaveOccurred())
49				server.Start()
50
51				buffer = gbytes.NewBuffer()
52				server.SetOutputDestination(buffer)
53
54				client = parallel_support.NewClient(server.Address())
55				Eventually(client.Connect).Should(BeTrue())
56
57				DeferCleanup(server.Close)
58				DeferCleanup(client.Close)
59			})
60
61			Describe("Reporting endpoints", func() {
62				var beginReport, thirdBeginReport types.Report
63				var endReport1, endReport2, endReport3 types.Report
64				var specReportA, specReportB, specReportC types.SpecReport
65
66				var t time.Time
67
68				BeforeEach(func() {
69					beginReport = types.Report{SuiteDescription: "my sweet suite"}
70					thirdBeginReport = types.Report{SuiteDescription: "last one in gets forwarded"}
71
72					specReportA = types.SpecReport{LeafNodeText: "A"}
73					specReportB = types.SpecReport{LeafNodeText: "B"}
74					specReportC = types.SpecReport{LeafNodeText: "C"}
75
76					t = time.Now()
77
78					endReport1 = types.Report{StartTime: t.Add(-time.Second), EndTime: t.Add(time.Second), SuiteSucceeded: true, SpecReports: types.SpecReports{specReportA}}
79					endReport2 = types.Report{StartTime: t.Add(-2 * time.Second), EndTime: t.Add(time.Second), SuiteSucceeded: true, SpecReports: types.SpecReports{specReportB}}
80					endReport3 = types.Report{StartTime: t.Add(-time.Second), EndTime: t.Add(2 * time.Second), SuiteSucceeded: false, SpecReports: types.SpecReports{specReportC}}
81				})
82
83				Context("before all procs have reported SuiteWillBegin", func() {
84					BeforeEach(func() {
85						Ω(client.PostSuiteWillBegin(beginReport)).Should(Succeed())
86						Ω(client.PostDidRun(specReportA)).Should(Succeed())
87						Ω(client.PostSuiteWillBegin(beginReport)).Should(Succeed())
88						Ω(client.PostDidRun(specReportB)).Should(Succeed())
89					})
90
91					It("should not forward anything to the attached reporter", func() {
92						Ω(reporter.Begin).Should(BeZero())
93						Ω(reporter.Will).Should(BeEmpty())
94						Ω(reporter.Did).Should(BeEmpty())
95					})
96
97					Context("when the final proc reports SuiteWillBegin", func() {
98						BeforeEach(func() {
99							Ω(client.PostSuiteWillBegin(thirdBeginReport)).Should(Succeed())
100						})
101
102						It("forwards to SuiteWillBegin and catches up on any received summaries", func() {
103							Ω(reporter.Begin).Should(Equal(thirdBeginReport))
104							Ω(reporter.Will.Names()).Should(ConsistOf("A", "B"))
105							Ω(reporter.Did.Names()).Should(ConsistOf("A", "B"))
106						})
107
108						Context("any subsequent summaries", func() {
109							BeforeEach(func() {
110								Ω(client.PostDidRun(specReportC)).Should(Succeed())
111							})
112
113							It("are forwarded immediately", func() {
114								Ω(reporter.Will.Names()).Should(ConsistOf("A", "B", "C"))
115								Ω(reporter.Did.Names()).Should(ConsistOf("A", "B", "C"))
116							})
117						})
118
119						Context("when SuiteDidEnd start arriving", func() {
120							BeforeEach(func() {
121								Ω(client.PostSuiteDidEnd(endReport1)).Should(Succeed())
122								Ω(client.PostSuiteDidEnd(endReport2)).Should(Succeed())
123							})
124
125							It("does not forward them yet...", func() {
126								Ω(reporter.End).Should(BeZero())
127							})
128
129							It("doesn't signal it's done", func() {
130								Ω(server.GetSuiteDone()).ShouldNot(BeClosed())
131							})
132
133							Context("when the final SuiteDidEnd arrive", func() {
134								BeforeEach(func() {
135									Ω(client.PostSuiteDidEnd(endReport3)).Should(Succeed())
136								})
137
138								It("forwards the aggregation of all received end summaries", func() {
139									Ω(reporter.End.StartTime.Unix()).Should(BeNumerically("~", t.Add(-2*time.Second).Unix()))
140									Ω(reporter.End.EndTime.Unix()).Should(BeNumerically("~", t.Add(2*time.Second).Unix()))
141									Ω(reporter.End.RunTime).Should(BeNumerically("~", 4*time.Second))
142									Ω(reporter.End.SuiteSucceeded).Should(BeFalse())
143									Ω(reporter.End.SpecReports).Should(ConsistOf(specReportA, specReportB, specReportC))
144								})
145
146								It("should signal it's done", func() {
147									Ω(server.GetSuiteDone()).Should(BeClosed())
148								})
149							})
150						})
151					})
152				})
153			})
154
155			Describe("supporting ReportEntries (which RPC struggled with when I first implemented it)", func() {
156				BeforeEach(func() {
157					Ω(client.PostSuiteWillBegin(types.Report{SuiteDescription: "my sweet suite"})).Should(Succeed())
158					Ω(client.PostSuiteWillBegin(types.Report{SuiteDescription: "my sweet suite"})).Should(Succeed())
159					Ω(client.PostSuiteWillBegin(types.Report{SuiteDescription: "my sweet suite"})).Should(Succeed())
160				})
161				It("can pass in ReportEntries that include custom types", func() {
162					cl := types.NewCodeLocation(0)
163					entry, err := internal.NewReportEntry("No Value Entry", cl)
164					Ω(err).ShouldNot(HaveOccurred())
165					Ω(client.PostDidRun(types.SpecReport{
166						LeafNodeText:  "no-value",
167						ReportEntries: types.ReportEntries{entry},
168					})).Should(Succeed())
169
170					entry, err = internal.NewReportEntry("String Value Entry", cl, "The String")
171					Ω(err).ShouldNot(HaveOccurred())
172					Ω(client.PostDidRun(types.SpecReport{
173						LeafNodeText:  "string-value",
174						ReportEntries: types.ReportEntries{entry},
175					})).Should(Succeed())
176
177					entry, err = internal.NewReportEntry("Custom Type Value Entry", cl, ColorableStringerStruct{Label: "apples", Count: 17})
178					Ω(err).ShouldNot(HaveOccurred())
179					Ω(client.PostDidRun(types.SpecReport{
180						LeafNodeText:  "custom-value",
181						ReportEntries: types.ReportEntries{entry},
182					})).Should(Succeed())
183
184					Ω(reporter.Did.Find("no-value").ReportEntries[0].Name).Should(Equal("No Value Entry"))
185					Ω(reporter.Did.Find("no-value").ReportEntries[0].StringRepresentation()).Should(Equal(""))
186
187					Ω(reporter.Did.Find("string-value").ReportEntries[0].Name).Should(Equal("String Value Entry"))
188					Ω(reporter.Did.Find("string-value").ReportEntries[0].StringRepresentation()).Should(Equal("The String"))
189
190					Ω(reporter.Did.Find("custom-value").ReportEntries[0].Name).Should(Equal("Custom Type Value Entry"))
191					Ω(reporter.Did.Find("custom-value").ReportEntries[0].StringRepresentation()).Should(Equal("{{red}}apples {{green}}17{{/}}"))
192				})
193			})
194
195			Describe("Streaming output", func() {
196				It("is configured to stream to stdout", func() {
197					server, err := parallel_support.NewServer(3, reporter)
198					Ω(err).ShouldNot(HaveOccurred())
199					Ω(server.GetOutputDestination().(*os.File).Fd()).Should(Equal(uintptr(1)))
200				})
201
202				It("streams output to the provided buffer", func() {
203					n, err := client.Write([]byte("hello"))
204					Ω(n).Should(Equal(5))
205					Ω(err).ShouldNot(HaveOccurred())
206					Ω(buffer).Should(gbytes.Say("hello"))
207				})
208			})
209
210			Describe("Synchronization endpoints", func() {
211				var proc1Exited, proc2Exited, proc3Exited chan interface{}
212				BeforeEach(func() {
213					proc1Exited, proc2Exited, proc3Exited = make(chan interface{}), make(chan interface{}), make(chan interface{})
214					aliveFunc := func(c chan interface{}) func() bool {
215						return func() bool {
216							select {
217							case <-c:
218								return false
219							default:
220								return true
221							}
222						}
223					}
224					server.RegisterAlive(1, aliveFunc(proc1Exited))
225					server.RegisterAlive(2, aliveFunc(proc2Exited))
226					server.RegisterAlive(3, aliveFunc(proc3Exited))
227				})
228
229				Describe("Managing SynchronizedBeforeSuite synchronization", func() {
230					Context("when proc 1 succeeds and returns data", func() {
231						It("passes that data along to other procs", func() {
232							Ω(client.PostSynchronizedBeforeSuiteCompleted(types.SpecStatePassed, []byte("hello there"))).Should(Succeed())
233							state, data, err := client.BlockUntilSynchronizedBeforeSuiteData()
234							Ω(state).Should(Equal(types.SpecStatePassed))
235							Ω(data).Should(Equal([]byte("hello there")))
236							Ω(err).ShouldNot(HaveOccurred())
237						})
238					})
239
240					Context("when proc 1 succeeds and the data happens to be nil", func() {
241						It("passes reports success and returns nil", func() {
242							Ω(client.PostSynchronizedBeforeSuiteCompleted(types.SpecStatePassed, nil)).Should(Succeed())
243							state, data, err := client.BlockUntilSynchronizedBeforeSuiteData()
244							Ω(state).Should(Equal(types.SpecStatePassed))
245							Ω(data).Should(BeNil())
246							Ω(err).ShouldNot(HaveOccurred())
247						})
248					})
249
250					Context("when proc 1 is skipped", func() {
251						It("passes that state information along to the other procs", func() {
252							Ω(client.PostSynchronizedBeforeSuiteCompleted(types.SpecStateSkipped, nil)).Should(Succeed())
253							state, data, err := client.BlockUntilSynchronizedBeforeSuiteData()
254							Ω(state).Should(Equal(types.SpecStateSkipped))
255							Ω(data).Should(BeNil())
256							Ω(err).ShouldNot(HaveOccurred())
257						})
258					})
259
260					Context("when proc 1 fails", func() {
261						It("passes that state information along to the other procs", func() {
262							Ω(client.PostSynchronizedBeforeSuiteCompleted(types.SpecStateFailed, nil)).Should(Succeed())
263							state, data, err := client.BlockUntilSynchronizedBeforeSuiteData()
264							Ω(state).Should(Equal(types.SpecStateFailed))
265							Ω(data).Should(BeNil())
266							Ω(err).ShouldNot(HaveOccurred())
267						})
268					})
269
270					Context("when proc 1 disappears before reporting back", func() {
271						It("returns a meaningful error", func() {
272							close(proc1Exited)
273							state, data, err := client.BlockUntilSynchronizedBeforeSuiteData()
274							Ω(state).Should(Equal(types.SpecStateInvalid))
275							Ω(data).Should(BeNil())
276							Ω(err).Should(MatchError(types.GinkgoErrors.SynchronizedBeforeSuiteDisappearedOnProc1()))
277						})
278					})
279
280					Context("when proc 1 hasn't responded yet", func() {
281						It("blocks until it does", func() {
282							done := make(chan interface{})
283							go func() {
284								defer GinkgoRecover()
285								state, data, err := client.BlockUntilSynchronizedBeforeSuiteData()
286								Ω(state).Should(Equal(types.SpecStatePassed))
287								Ω(data).Should(Equal([]byte("hello there")))
288								Ω(err).ShouldNot(HaveOccurred())
289								close(done)
290							}()
291							Consistently(done).ShouldNot(BeClosed())
292							Ω(client.PostSynchronizedBeforeSuiteCompleted(types.SpecStatePassed, []byte("hello there"))).Should(Succeed())
293							Eventually(done).Should(BeClosed())
294						})
295					})
296				})
297
298				Describe("BlockUntilNonprimaryProcsHaveFinished", func() {
299					It("blocks until non-primary procs exit", func() {
300						done := make(chan interface{})
301						go func() {
302							defer GinkgoRecover()
303							Ω(client.BlockUntilNonprimaryProcsHaveFinished()).Should(Succeed())
304							close(done)
305						}()
306						Consistently(done).ShouldNot(BeClosed())
307						close(proc2Exited)
308						Consistently(done).ShouldNot(BeClosed())
309						close(proc3Exited)
310						Eventually(done).Should(BeClosed())
311					})
312				})
313
314				Describe("BlockUntilAggregatedNonprimaryProcsReport", func() {
315					var specReportA, specReportB types.SpecReport
316					var endReport2, endReport3 types.Report
317
318					BeforeEach(func() {
319						specReportA = types.SpecReport{LeafNodeText: "A"}
320						specReportB = types.SpecReport{LeafNodeText: "B"}
321						endReport2 = types.Report{SpecReports: types.SpecReports{specReportA}}
322						endReport3 = types.Report{SpecReports: types.SpecReports{specReportB}}
323					})
324
325					It("blocks until all non-primary procs exit, then returns the aggregated report", func() {
326						done := make(chan interface{})
327						go func() {
328							defer GinkgoRecover()
329							report, err := client.BlockUntilAggregatedNonprimaryProcsReport()
330							Ω(err).ShouldNot(HaveOccurred())
331							Ω(report.SpecReports).Should(ConsistOf(specReportA, specReportB))
332							close(done)
333						}()
334						Consistently(done).ShouldNot(BeClosed())
335
336						Ω(client.PostSuiteDidEnd(endReport2)).Should(Succeed())
337						close(proc2Exited)
338						Consistently(done).ShouldNot(BeClosed())
339
340						Ω(client.PostSuiteDidEnd(endReport3)).Should(Succeed())
341						close(proc3Exited)
342						Eventually(done).Should(BeClosed())
343					})
344
345					Context("when a non-primary proc disappears without reporting back", func() {
346						It("blocks returns an appropriate error", func() {
347							done := make(chan interface{})
348							go func() {
349								defer GinkgoRecover()
350								report, err := client.BlockUntilAggregatedNonprimaryProcsReport()
351								Ω(err).Should(Equal(types.GinkgoErrors.AggregatedReportUnavailableDueToNodeDisappearing()))
352								Ω(report).Should(BeZero())
353								close(done)
354							}()
355							Consistently(done).ShouldNot(BeClosed())
356
357							Ω(client.PostSuiteDidEnd(endReport2)).Should(Succeed())
358							close(proc2Exited)
359							Consistently(done).ShouldNot(BeClosed())
360
361							close(proc3Exited)
362							Eventually(done).Should(BeClosed())
363						})
364					})
365				})
366
367				Describe("Fetching counters", func() {
368					It("returns ascending counters", func() {
369						Ω(client.FetchNextCounter()).Should(Equal(0))
370						Ω(client.FetchNextCounter()).Should(Equal(1))
371						Ω(client.FetchNextCounter()).Should(Equal(2))
372						Ω(client.FetchNextCounter()).Should(Equal(3))
373					})
374				})
375
376				Describe("Aborting", func() {
377					It("should not abort by default", func() {
378						Ω(client.ShouldAbort()).Should(BeFalse())
379					})
380
381					Context("when told to abort", func() {
382						BeforeEach(func() {
383							Ω(client.PostAbort()).Should(Succeed())
384						})
385
386						It("should abort", func() {
387							Ω(client.ShouldAbort()).Should(BeTrue())
388						})
389					})
390				})
391
392			})
393		})
394	}
395})
396
Full Screen

fake_reporter.go

Source: fake_reporter.go Github

copy
1package test_helpers
2
3import (
4	"reflect"
5
6	. "github.com/onsi/gomega"
7	. "github.com/onsi/gomega/gstruct"
8
9	"github.com/onsi/ginkgo/v2/internal/interrupt_handler"
10	"github.com/onsi/ginkgo/v2/types"
11)
12
13/*
14
15A FakeReporter and collection of matchers to match against reported suite and spec summaries
16
17*/
18
19type Reports []types.SpecReport
20
21func (s Reports) FindByLeafNodeType(nodeTypes types.NodeType) types.SpecReport {
22	for _, report := range s {
23		if report.LeafNodeType.Is(nodeTypes) {
24			return report
25		}
26	}
27
28	return types.SpecReport{}
29}
30
31func (s Reports) Find(name string) types.SpecReport {
32	for _, report := range s {
33		if report.LeafNodeText == name {
34			return report
35		}
36	}
37
38	return types.SpecReport{}
39}
40
41func (s Reports) FindByFullText(text string) types.SpecReport {
42	for _, report := range s {
43		if report.FullText() == text {
44			return report
45		}
46	}
47
48	return types.SpecReport{}
49}
50
51func (s Reports) Names() []string {
52	out := []string{}
53	for _, report := range s {
54		if report.LeafNodeText != "" {
55			out = append(out, report.LeafNodeText)
56		}
57	}
58	return out
59}
60
61func (s Reports) WithState(state types.SpecState) Reports {
62	out := Reports{}
63	for _, report := range s {
64		if report.State == state {
65			out = append(out, report)
66		}
67	}
68	return out
69}
70
71func (s Reports) WithLeafNodeType(nodeTypes types.NodeType) Reports {
72	out := Reports{}
73	for _, report := range s {
74		if report.LeafNodeType.Is(nodeTypes) {
75			out = append(out, report)
76		}
77	}
78	return out
79}
80
81type FakeReporter struct {
82	Begin types.Report
83	Will  Reports
84	Did   Reports
85	End   types.Report
86}
87
88func (r *FakeReporter) SuiteWillBegin(report types.Report) {
89	r.Begin = report
90}
91
92func (r *FakeReporter) WillRun(report types.SpecReport) {
93	r.Will = append(r.Will, report)
94}
95
96func (r *FakeReporter) DidRun(report types.SpecReport) {
97	r.Did = append(r.Did, report)
98}
99
100func (r *FakeReporter) SuiteDidEnd(report types.Report) {
101	r.End = report
102}
103
104type NSpecs int
105type NWillRun int
106type NPassed int
107type NSkipped int
108type NFailed int
109type NPending int
110type NFlaked int
111
112func BeASuiteSummary(options ...interface{}) OmegaMatcher {
113	type ReportStats struct {
114		Succeeded    bool
115		TotalSpecs   int
116		WillRunSpecs int
117		Passed       int
118		Skipped      int
119		Failed       int
120		Pending      int
121		Flaked       int
122	}
123	fields := Fields{
124		"Passed":     Equal(0),
125		"Skipped":    Equal(0),
126		"Failed":     Equal(0),
127		"Pending":    Equal(0),
128		"Flaked":     Equal(0),
129		"TotalSpecs": Equal(0),
130	}
131	for _, option := range options {
132		t := reflect.TypeOf(option)
133		if t.Kind() == reflect.Bool {
134			if option.(bool) {
135				fields["Succeeded"] = BeTrue()
136			} else {
137				fields["Succeeded"] = BeFalse()
138			}
139		} else if t == reflect.TypeOf(NSpecs(0)) {
140			fields["TotalSpecs"] = Equal(int(option.(NSpecs)))
141		} else if t == reflect.TypeOf(NWillRun(0)) {
142			fields["WillRunSpecs"] = Equal(int(option.(NWillRun)))
143		} else if t == reflect.TypeOf(NPassed(0)) {
144			fields["Passed"] = Equal(int(option.(NPassed)))
145		} else if t == reflect.TypeOf(NSkipped(0)) {
146			fields["Skipped"] = Equal(int(option.(NSkipped)))
147		} else if t == reflect.TypeOf(NFailed(0)) {
148			fields["Failed"] = Equal(int(option.(NFailed)))
149		} else if t == reflect.TypeOf(NPending(0)) {
150			fields["Pending"] = Equal(int(option.(NPending)))
151		} else if t == reflect.TypeOf(NFlaked(0)) {
152			fields["Flaked"] = Equal(int(option.(NFlaked)))
153		}
154	}
155	return WithTransform(func(report types.Report) ReportStats {
156		specs := report.SpecReports.WithLeafNodeType(types.NodeTypeIt)
157		return ReportStats{
158			Succeeded:    report.SuiteSucceeded,
159			TotalSpecs:   report.PreRunStats.TotalSpecs,
160			WillRunSpecs: report.PreRunStats.SpecsThatWillRun,
161			Passed:       specs.CountWithState(types.SpecStatePassed),
162			Skipped:      specs.CountWithState(types.SpecStateSkipped),
163			Failed:       specs.CountWithState(types.SpecStateFailureStates),
164			Pending:      specs.CountWithState(types.SpecStatePending),
165			Flaked:       specs.CountOfFlakedSpecs(),
166		}
167	}, MatchFields(IgnoreExtras, fields))
168}
169
170type CapturedGinkgoWriterOutput string
171type CapturedStdOutput string
172type NumAttempts int
173
174func HavePassed(options ...interface{}) OmegaMatcher {
175	matchers := []OmegaMatcher{
176		HaveField("State", types.SpecStatePassed),
177		HaveField("Failure", BeZero()),
178	}
179	for _, option := range options {
180		var matcher OmegaMatcher
181		switch v := option.(type) {
182		case CapturedGinkgoWriterOutput:
183			matcher = HaveField("CapturedGinkgoWriterOutput", string(v))
184		case CapturedStdOutput:
185			matcher = HaveField("CapturedStdOutErr", string(v))
186		case types.NodeType:
187			matcher = HaveField("LeafNodeType", v)
188		case NumAttempts:
189			matcher = HaveField("NumAttempts", int(v))
190		}
191		if matcher != nil {
192			matchers = append(matchers, matcher)
193		}
194	}
195
196	return And(matchers...)
197}
198
199func BePending() OmegaMatcher {
200	return And(
201		HaveField("State", types.SpecStatePending),
202		HaveField("Failure", BeZero()),
203	)
204}
205
206func HaveBeenSkipped() OmegaMatcher {
207	return And(
208		HaveField("State", types.SpecStateSkipped),
209		HaveField("Failure", BeZero()),
210	)
211}
212
213func HaveBeenSkippedWithMessage(message string, options ...interface{}) OmegaMatcher {
214	matchers := []OmegaMatcher{
215		HaveField("State", types.SpecStateSkipped),
216		HaveField("Failure.Message", Equal(message)),
217	}
218
219	for _, option := range options {
220		switch v := option.(type) {
221		case NumAttempts:
222			matchers = append(matchers, HaveField("NumAttempts", int(v)))
223		}
224	}
225	return And(matchers...)
226}
227
228func HaveBeenInterrupted(cause interrupt_handler.InterruptCause) OmegaMatcher {
229	return And(
230		HaveField("State", types.SpecStateInterrupted),
231		HaveField("Failure.Message", HavePrefix(cause.String())),
232	)
233}
234
235type FailureNodeType types.NodeType
236
237func failureMatcherForState(state types.SpecState, messageField string, options ...interface{}) OmegaMatcher {
238	matchers := []OmegaMatcher{
239		HaveField("State", state),
240	}
241	for _, option := range options {
242		var matcher OmegaMatcher
243		switch v := option.(type) {
244		case CapturedGinkgoWriterOutput:
245			matcher = HaveField("CapturedGinkgoWriterOutput", string(v))
246		case CapturedStdOutput:
247			matcher = HaveField("CapturedStdOutErr", string(v))
248		case types.NodeType:
249			matcher = HaveField("LeafNodeType", v)
250		case types.FailureNodeContext:
251			matcher = HaveField("Failure.FailureNodeContext", v)
252		case string:
253			matcher = HaveField(messageField, ContainSubstring(v))
254		case types.CodeLocation:
255			matcher = HaveField("Failure.Location", v)
256		case FailureNodeType:
257			matcher = HaveField("Failure.FailureNodeType", types.NodeType(v))
258		case NumAttempts:
259			matcher = HaveField("NumAttempts", int(v))
260		}
261		if matcher != nil {
262			matchers = append(matchers, matcher)
263		}
264	}
265
266	return And(matchers...)
267}
268
269func HaveFailed(options ...interface{}) OmegaMatcher {
270	return failureMatcherForState(types.SpecStateFailed, "Failure.Message", options...)
271}
272
273func HaveAborted(options ...interface{}) OmegaMatcher {
274	return failureMatcherForState(types.SpecStateAborted, "Failure.Message", options...)
275}
276
277func HavePanicked(options ...interface{}) OmegaMatcher {
278	return failureMatcherForState(types.SpecStatePanicked, "Failure.ForwardedPanic", options...)
279}
280
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
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)