github.com/onsi/ginkgo@v1.16.6-0.20211118180735-4e1925ba4c95/internal/internal_integration/skip_test.go (about)

     1  package internal_integration_test
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo"
     5  	"github.com/onsi/ginkgo/types"
     6  	. "github.com/onsi/gomega"
     7  
     8  	. "github.com/onsi/ginkgo/internal/test_helpers"
     9  )
    10  
    11  var _ = Describe("Skip", func() {
    12  	Context("When Skip() is called in individual subject and setup nodes", func() {
    13  		BeforeEach(func() {
    14  			success, _ := RunFixture("Skip() tests", func() {
    15  				Describe("container to ensure order", func() {
    16  					It("A", rt.T("A"))
    17  					Describe("container", func() {
    18  						BeforeEach(rt.T("bef", func() {
    19  							failer.Skip("skip in Bef", cl)
    20  							panic("boom") //simulates what Ginkgo DSL does
    21  						}))
    22  						It("B", rt.T("B"))
    23  						It("C", rt.T("C"))
    24  						AfterEach(rt.T("aft"))
    25  					})
    26  					It("D", rt.T("D", func() {
    27  						failer.Skip("skip D", cl)
    28  						panic("boom") //simulates what Ginkgo DSL does
    29  					}))
    30  				})
    31  			})
    32  
    33  			Ω(success).Should(BeTrue())
    34  		})
    35  
    36  		It("skips the tests that are Skipped()", func() {
    37  			Ω(rt).Should(HaveTracked("A", "bef", "aft", "bef", "aft", "D"))
    38  			Ω(reporter.Did.WithState(types.SpecStatePassed).Names()).Should(ConsistOf("A"))
    39  			Ω(reporter.Did.WithState(types.SpecStateSkipped).Names()).Should(ConsistOf("B", "C", "D"))
    40  
    41  			Ω(reporter.Did.Find("B").Failure.Message).Should(Equal("skip in Bef"))
    42  			Ω(reporter.Did.Find("B").Failure.Location).Should(Equal(cl))
    43  
    44  			Ω(reporter.Did.Find("D").Failure.Message).Should(Equal("skip D"))
    45  			Ω(reporter.Did.Find("D").Failure.Location).Should(Equal(cl))
    46  		})
    47  
    48  		It("report on the suite with accurate numbers", func() {
    49  			Ω(reporter.End).Should(BeASuiteSummary(true, NPassed(1), NSkipped(3), NPending(0), NSpecs(4), NWillRun(4)))
    50  		})
    51  	})
    52  
    53  	Context("when Skip() is called in BeforeSuite", func() {
    54  		BeforeEach(func() {
    55  			success, _ := RunFixture("Skip() BeforeSuite", func() {
    56  				BeforeSuite(func() {
    57  					rt.Run("befs")
    58  					Skip("skip please")
    59  				})
    60  				Describe("container to ensure order", func() {
    61  					It("A", rt.T("A"))
    62  					It("B", rt.T("B"))
    63  					It("C", rt.T("C"))
    64  				})
    65  			})
    66  
    67  			Ω(success).Should(BeTrue())
    68  		})
    69  
    70  		It("skips all the tsts", func() {
    71  			Ω(rt).Should(HaveTracked("befs"))
    72  			Ω(reporter.Did.FindByLeafNodeType(types.NodeTypeBeforeSuite)).Should(HaveBeenSkippedWithMessage("skip please"))
    73  			Ω(reporter.Did.Find("A")).Should(HaveBeenSkipped())
    74  			Ω(reporter.Did.Find("B")).Should(HaveBeenSkipped())
    75  			Ω(reporter.Did.Find("C")).Should(HaveBeenSkipped())
    76  		})
    77  
    78  		It("report on the suite with accurate numbers", func() {
    79  			Ω(reporter.End).Should(BeASuiteSummary(true, NPassed(0), NSkipped(3), NPending(0), NSpecs(3), NWillRun(3)))
    80  			Ω(reporter.End.SpecialSuiteFailureReasons).Should(ContainElement("Suite skipped in BeforeSuite"))
    81  		})
    82  	})
    83  })