-
-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PreviewSpecs() to enable programmatic preview access to the suite…
… report
- Loading branch information
Showing
7 changed files
with
202 additions
and
27 deletions.
There are no files selected for viewing
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
41 changes: 41 additions & 0 deletions
41
integration/_fixtures/preview_fixture/preview_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,41 @@ | ||
package preview_fixture_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestPreviewFixture(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
if os.Getenv("RUN") == "true" { | ||
RunSpecs(t, "PreviewFixture Suite", Label("suite-label")) | ||
} | ||
if os.Getenv("PREVIEW") == "true" { | ||
report := PreviewSpecs("PreviewFixture Suite", Label("suite-label")) | ||
for _, spec := range report.SpecReports { | ||
fmt.Println(spec.State, spec.FullText()) | ||
} | ||
} | ||
} | ||
|
||
var _ = Describe("specs", func() { | ||
It("A", Label("elephant"), func() { | ||
|
||
}) | ||
|
||
It("B", Label("elephant"), func() { | ||
|
||
}) | ||
|
||
It("C", func() { | ||
|
||
}) | ||
|
||
It("D", func() { | ||
|
||
}) | ||
}) |
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,45 @@ | ||
package integration_test | ||
|
||
import ( | ||
"os" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
"github.com/onsi/gomega/gexec" | ||
) | ||
|
||
var _ = Describe("Preview", func() { | ||
BeforeEach(func() { | ||
fm.MountFixture("preview") | ||
}) | ||
|
||
It("previews the specs, honoring the passed in flags", func() { | ||
os.Setenv("PREVIEW", "true") | ||
DeferCleanup(os.Unsetenv, "PREVIEW") | ||
session := startGinkgo(fm.PathTo("preview"), "--label-filter=elephant") | ||
Eventually(session).Should(gexec.Exit(0)) | ||
Ω(session).Should(gbytes.Say("passed specs A")) | ||
Ω(session).Should(gbytes.Say("passed specs B")) | ||
Ω(session).Should(gbytes.Say("skipped specs C")) | ||
Ω(session).Should(gbytes.Say("skipped specs D")) | ||
}) | ||
|
||
It("fails if running in parallel", func() { | ||
os.Setenv("PREVIEW", "true") | ||
DeferCleanup(os.Unsetenv, "PREVIEW") | ||
session := startGinkgo(fm.PathTo("preview"), "--procs=2") | ||
Eventually(session).Should(gexec.Exit(1)) | ||
Ω(session.Err).Should(gbytes.Say(`Ginkgo only supports PreviewSpecs\(\) in serial mode\.`)) | ||
}) | ||
|
||
It("fails if you attempt to both run and preview specs", func() { | ||
os.Setenv("PREVIEW", "true") | ||
DeferCleanup(os.Unsetenv, "PREVIEW") | ||
os.Setenv("RUN", "true") | ||
DeferCleanup(os.Unsetenv, "RUN") | ||
session := startGinkgo(fm.PathTo("preview")) | ||
Eventually(session).Should(gexec.Exit(1)) | ||
Ω(session).Should(gbytes.Say(`It looks like you are calling RunSpecs and PreviewSpecs in the same invocation`)) | ||
}) | ||
}) |
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