...

Source file src/github.com/onsi/ginkgo/v2/integration/_fixtures/timeline_fixture/timeline_fixture_suite_test.go

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

     1  package timeline_fixture_test
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	. "github.com/onsi/ginkgo/v2"
     8  	"github.com/onsi/ginkgo/v2/types"
     9  	. "github.com/onsi/gomega"
    10  )
    11  
    12  func TestTimelineFixture(t *testing.T) {
    13  	RegisterFailHandler(Fail)
    14  	RunSpecs(t, "TimelineFixture Suite")
    15  }
    16  
    17  var _ = Describe("a full timeline", Serial, func() {
    18  	Describe("a flaky test", func() {
    19  		BeforeEach(func() {
    20  			By("logging some events")
    21  			GinkgoWriter.Println("hello!")
    22  			AddReportEntry("a report!", "Of {{bold}}great{{/}} value")
    23  			DeferCleanup(func() {
    24  				By("cleaning up a bit", func() {
    25  					time.Sleep(time.Millisecond * 50)
    26  					GinkgoWriter.Println("all done!")
    27  				})
    28  			})
    29  		})
    30  
    31  		i := 0
    32  
    33  		It("retries a few times", func() {
    34  			i += 1
    35  			GinkgoWriter.Println("let's try...")
    36  			if i < 3 {
    37  				Fail("bam!")
    38  			}
    39  			GinkgoWriter.Println("hooray!")
    40  		}, FlakeAttempts(3))
    41  
    42  		AfterEach(func() {
    43  			if i == 3 {
    44  				GinkgoWriter.Println("feeling sleepy...")
    45  				time.Sleep(time.Millisecond * 200)
    46  			}
    47  		}, PollProgressAfter(time.Millisecond*100))
    48  	})
    49  
    50  	Describe("a test with multiple failures", func() {
    51  		It("times out", func(ctx SpecContext) {
    52  			By("waiting...")
    53  			<-ctx.Done()
    54  			GinkgoWriter.Println("then failing!")
    55  			Fail("welp")
    56  		}, NodeTimeout(time.Millisecond*100))
    57  
    58  		AfterEach(func() {
    59  			panic("aaah!")
    60  		})
    61  	})
    62  
    63  	It("passes happily", func() {
    64  		AddReportEntry("a verbose-only report", types.ReportEntryVisibilityFailureOrVerbose)
    65  		AddReportEntry("a hidden report", types.ReportEntryVisibilityNever)
    66  	})
    67  })
    68  

View as plain text