-
-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow MustPassRepeatedly decorator to be set at suite level (#1266
- Loading branch information
Showing
7 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ure/config_override_fixture_suite_test.go → ...ure/config_override_fixture_suite_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package config_override_fixture_test | ||
package config_override_label_filter_fixture_test | ||
|
||
import ( | ||
"testing" | ||
|
21 changes: 21 additions & 0 deletions
21
...xtures/config_override_must_pass_repeatedly_fixture/config_override_fixture_suite_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package config_override_label_filter_fixture_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestConfigOverrideFixture(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
suiteConfig, reporterConfig := GinkgoConfiguration() | ||
suiteConfig.MustPassRepeatedly = 10 | ||
RunSpecs(t, "ConfigOverrideFixture Suite", suiteConfig, reporterConfig) | ||
} | ||
|
||
var _ = Describe("tests", func() { | ||
It("suite config overrides decorator", MustPassRepeatedly(2), func() { | ||
Ω(CurrentSpecReport().MaxMustPassRepeatedly).Should(Equal(10)) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
internal/internal_integration/config_must_pass_repeatedly_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package internal_integration_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/ginkgo/v2/internal/test_helpers" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("when config.MustPassRepeatedly is greater than 1", func() { | ||
var success bool | ||
JustBeforeEach(func() { | ||
var counterB int | ||
success, _ = RunFixture("flakey success", func() { | ||
It("A", func() {}) | ||
It("B", func() { | ||
counterB += 1 | ||
if counterB == 8 { | ||
F(fmt.Sprintf("C - %d", counterB)) | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
Context("when all tests pass", func() { | ||
BeforeEach(func() { | ||
conf.MustPassRepeatedly = 5 | ||
}) | ||
|
||
It("reports that the suite passed", func() { | ||
Ω(success).Should(BeTrue()) | ||
Ω(reporter.End).Should(BeASuiteSummary(NSpecs(2), NFailed(0), NPassed(2))) | ||
}) | ||
|
||
It("reports that the tests passed with the correct number of attempts", func() { | ||
Ω(reporter.Did.Find("A")).Should(HavePassed(NumAttempts(5))) | ||
Ω(reporter.Did.Find("B")).Should(HavePassed(NumAttempts(5))) | ||
}) | ||
}) | ||
|
||
Context("when a test fails", func() { | ||
BeforeEach(func() { | ||
conf.MustPassRepeatedly = 10 | ||
}) | ||
|
||
It("reports that the suite failed", func() { | ||
Ω(success).Should(BeFalse()) | ||
Ω(reporter.End).Should(BeASuiteSummary(NSpecs(2), NFailed(1), NPassed(1))) | ||
}) | ||
|
||
It("reports that the tests failed with the correct number of attempts", func() { | ||
Ω(reporter.Did.Find("A")).Should(HavePassed(NumAttempts(10))) | ||
Ω(reporter.Did.Find("B")).Should(HaveFailed(NumAttempts(8))) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters