|
| 1 | +package internal_integration_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + . "github.com/onsi/ginkgo/v2" |
| 7 | + . "github.com/onsi/ginkgo/v2/internal/test_helpers" |
| 8 | + . "github.com/onsi/gomega" |
| 9 | +) |
| 10 | + |
| 11 | +var _ = Describe("when config.MustPassRepeatedly is greater than 1", func() { |
| 12 | + var success bool |
| 13 | + JustBeforeEach(func() { |
| 14 | + var counterB int |
| 15 | + success, _ = RunFixture("flakey success", func() { |
| 16 | + It("A", func() {}) |
| 17 | + It("B", func() { |
| 18 | + counterB += 1 |
| 19 | + if counterB == 8 { |
| 20 | + F(fmt.Sprintf("C - %d", counterB)) |
| 21 | + } |
| 22 | + }) |
| 23 | + }) |
| 24 | + }) |
| 25 | + |
| 26 | + Context("when all tests pass", func() { |
| 27 | + BeforeEach(func() { |
| 28 | + conf.MustPassRepeatedly = 5 |
| 29 | + }) |
| 30 | + |
| 31 | + It("reports that the suite passed", func() { |
| 32 | + Ω(success).Should(BeTrue()) |
| 33 | + Ω(reporter.End).Should(BeASuiteSummary(NSpecs(2), NFailed(0), NPassed(2))) |
| 34 | + }) |
| 35 | + |
| 36 | + It("reports that the tests passed with the correct number of attempts", func() { |
| 37 | + Ω(reporter.Did.Find("A")).Should(HavePassed(NumAttempts(5))) |
| 38 | + Ω(reporter.Did.Find("B")).Should(HavePassed(NumAttempts(5))) |
| 39 | + }) |
| 40 | + }) |
| 41 | + |
| 42 | + Context("when a test fails", func() { |
| 43 | + BeforeEach(func() { |
| 44 | + conf.MustPassRepeatedly = 10 |
| 45 | + }) |
| 46 | + |
| 47 | + It("reports that the suite failed", func() { |
| 48 | + Ω(success).Should(BeFalse()) |
| 49 | + Ω(reporter.End).Should(BeASuiteSummary(NSpecs(2), NFailed(1), NPassed(1))) |
| 50 | + }) |
| 51 | + |
| 52 | + It("reports that the tests failed with the correct number of attempts", func() { |
| 53 | + Ω(reporter.Did.Find("A")).Should(HavePassed(NumAttempts(10))) |
| 54 | + Ω(reporter.Did.Find("B")).Should(HaveFailed(NumAttempts(8))) |
| 55 | + }) |
| 56 | + }) |
| 57 | +}) |
0 commit comments