...

Source file src/github.com/onsi/ginkgo/v2/integration/_fixtures/nondeterministic_fixture/nondeterministic_fixture_suite_test.go

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

     1  package nondeterministic_fixture_test
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	. "github.com/onsi/ginkgo/v2"
     8  	"github.com/onsi/ginkgo/v2/types"
     9  	. "github.com/onsi/gomega"
    10  )
    11  
    12  func TestNondeterministicFixture(t *testing.T) {
    13  	RegisterFailHandler(Fail)
    14  	RunSpecs(t, "NondeterministicFixture Suite")
    15  }
    16  
    17  var _ = ReportAfterSuite("ensure all specs ran correctly", func(report types.Report) {
    18  	specs := report.SpecReports.WithLeafNodeType(types.NodeTypeIt)
    19  	orderedTexts := []string{}
    20  	textCounts := map[string]int{}
    21  	for _, spec := range specs {
    22  		text := spec.FullText()
    23  		textCounts[text] += 1
    24  		if strings.HasPrefix(text, "ordered") {
    25  			orderedTexts = append(orderedTexts, spec.LeafNodeText)
    26  		}
    27  	}
    28  
    29  	By("ensuring there are no duplicates")
    30  	for text, count := range textCounts {
    31  		Ω(count).Should(Equal(1), text)
    32  	}
    33  
    34  	By("ensuring ordered specs are strictly preserved")
    35  	Ω(orderedTexts).Should(Equal([]string{"always", "runs", "in", "order"}))
    36  })
    37  

View as plain text