suite_command_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package integration_test
  2. import (
  3. . "github.com/onsi/ginkgo"
  4. . "github.com/onsi/gomega"
  5. "github.com/onsi/gomega/gexec"
  6. )
  7. var _ = Describe("Suite Command Specs", func() {
  8. var pathToTest string
  9. BeforeEach(func() {
  10. pathToTest = tmpPath("suite_command")
  11. copyIn("suite_command_tests", pathToTest)
  12. })
  13. It("Runs command after suite echoing out suite data, properly reporting suite name and passing status in successful command output", func() {
  14. command := "-afterSuiteHook=echo THIS IS A (ginkgo-suite-passed) TEST OF THE (ginkgo-suite-name) SYSTEM, THIS IS ONLY A TEST"
  15. expected := "THIS IS A [PASS] TEST OF THE suite_command SYSTEM, THIS IS ONLY A TEST"
  16. session := startGinkgo(pathToTest, command)
  17. Eventually(session).Should(gexec.Exit(0))
  18. output := string(session.Out.Contents())
  19. Ω(output).Should(ContainSubstring("1 Passed"))
  20. Ω(output).Should(ContainSubstring("0 Failed"))
  21. Ω(output).Should(ContainSubstring("1 Pending"))
  22. Ω(output).Should(ContainSubstring("0 Skipped"))
  23. Ω(output).Should(ContainSubstring("Test Suite Passed"))
  24. Ω(output).Should(ContainSubstring("Post-suite command succeeded:"))
  25. Ω(output).Should(ContainSubstring(expected))
  26. })
  27. It("Runs command after suite reporting that command failed", func() {
  28. command := "-afterSuiteHook=exit 1"
  29. session := startGinkgo(pathToTest, command)
  30. Eventually(session).Should(gexec.Exit(0))
  31. output := string(session.Out.Contents())
  32. Ω(output).Should(ContainSubstring("1 Passed"))
  33. Ω(output).Should(ContainSubstring("0 Failed"))
  34. Ω(output).Should(ContainSubstring("1 Pending"))
  35. Ω(output).Should(ContainSubstring("0 Skipped"))
  36. Ω(output).Should(ContainSubstring("Test Suite Passed"))
  37. Ω(output).Should(ContainSubstring("Post-suite command failed:"))
  38. })
  39. It("Runs command after suite echoing out suite data, properly reporting suite name and failing status in successful command output", func() {
  40. command := "-afterSuiteHook=echo THIS IS A (ginkgo-suite-passed) TEST OF THE (ginkgo-suite-name) SYSTEM, THIS IS ONLY A TEST"
  41. expected := "THIS IS A [FAIL] TEST OF THE suite_command SYSTEM, THIS IS ONLY A TEST"
  42. session := startGinkgo(pathToTest, "-failOnPending=true", command)
  43. Eventually(session).Should(gexec.Exit(1))
  44. output := string(session.Out.Contents())
  45. Ω(output).Should(ContainSubstring("1 Passed"))
  46. Ω(output).Should(ContainSubstring("0 Failed"))
  47. Ω(output).Should(ContainSubstring("1 Pending"))
  48. Ω(output).Should(ContainSubstring("0 Skipped"))
  49. Ω(output).Should(ContainSubstring("Test Suite Failed"))
  50. Ω(output).Should(ContainSubstring("Post-suite command succeeded:"))
  51. Ω(output).Should(ContainSubstring(expected))
  52. })
  53. })