File: abort_test.go

package info (click to toggle)
golang-github-onsi-ginkgo-v2 2.15.0-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 4,112 kB
  • sloc: javascript: 59; sh: 14; makefile: 7
file content (47 lines) | stat: -rw-r--r-- 1,725 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package integration_test

import (
	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"

	"github.com/onsi/ginkgo/v2/internal/interrupt_handler"
	. "github.com/onsi/ginkgo/v2/internal/test_helpers"
	"github.com/onsi/ginkgo/v2/reporters"
	"github.com/onsi/ginkgo/v2/types"
)

var _ = Describe("Abort", func() {
	var session *gexec.Session
	BeforeEach(func() {
		fm.MountFixture("abort")
		session = startGinkgo(fm.PathTo("abort"), "--no-color", "--json-report=out.json", "--junit-report=out.xml", "--procs=2")
		Eventually(session).Should(gexec.Exit(1))
	})

	It("aborts the suite and does not run any subsequent tests", func() {
		Ω(session).Should(gbytes.Say("this suite needs to end now!"))
		Ω(string(session.Out.Contents())).ShouldNot(ContainSubstring("SHOULD NOT SEE THIS"))
	})

	It("reports on the test run correctly", func() {
		report := fm.LoadJSONReports("abort", "out.json")[0]
		specs := Reports(report.SpecReports)
		Ω(specs.Find("runs and passes")).Should(HavePassed())
		Ω(specs.Find("aborts")).Should(HaveAborted("this suite needs to end now!"))
		Ω(specs.Find("never runs")).Should(HaveBeenInterrupted(interrupt_handler.InterruptCauseAbortByOtherProcess))
		Ω(specs.Find("never runs either")).Should(HaveBeenSkipped())

		junitSuites := fm.LoadJUnitReport("abort", "out.xml")
		cases := junitSuites.TestSuites[0].TestCases
		var abortCase reporters.JUnitTestCase
		for _, testCase := range cases {
			if testCase.Status == types.SpecStateAborted.String() {
				abortCase = testCase
			}
		}
		Ω(abortCase.Failure.Message).Should(Equal("this suite needs to end now!"))
		Ω(abortCase.Failure.Type).Should(Equal("aborted"))
	})
})