...

Source file src/github.com/onsi/ginkgo/v2/integration/suite_command_test.go

Documentation: github.com/onsi/ginkgo/v2/integration

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

View as plain text