...

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

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

     1  package integration_test
     2  
     3  import (
     4  	"regexp"
     5  	"runtime"
     6  
     7  	. "github.com/onsi/ginkgo/v2"
     8  	. "github.com/onsi/gomega"
     9  	"github.com/onsi/gomega/gexec"
    10  )
    11  
    12  var _ = Describe("Verbose And Succinct Mode", func() {
    13  	denoter := "•"
    14  
    15  	if runtime.GOOS == "windows" {
    16  		denoter = "+"
    17  	}
    18  
    19  	Context("when running one package", func() {
    20  		BeforeEach(func() {
    21  			fm.MountFixture("passing_ginkgo_tests")
    22  		})
    23  
    24  		It("should default to non-succinct mode", func() {
    25  			session := startGinkgo(fm.PathTo("passing_ginkgo_tests"), "--no-color")
    26  			Eventually(session).Should(gexec.Exit(0))
    27  			output := session.Out.Contents()
    28  
    29  			Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
    30  		})
    31  	})
    32  
    33  	Context("when running more than one package", func() {
    34  		BeforeEach(func() {
    35  			fm.MountFixture("passing_ginkgo_tests")
    36  			fm.MountFixture("more_ginkgo_tests")
    37  		})
    38  
    39  		Context("with no flags set", func() {
    40  			It("should default to succinct mode", func() {
    41  				session := startGinkgo(fm.TmpDir, "--no-color", "passing_ginkgo_tests", "more_ginkgo_tests")
    42  				Eventually(session).Should(gexec.Exit(0))
    43  				output := session.Out.Contents()
    44  
    45  				Ω(output).Should(MatchRegexp(`\] Passing_ginkgo_tests Suite - 5/5 specs [%s]{5} SUCCESS!`, regexp.QuoteMeta(denoter)))
    46  				Ω(output).Should(MatchRegexp(`\] More_ginkgo_tests Suite - 3/3 specs [%s]{3} SUCCESS!`, regexp.QuoteMeta(denoter)))
    47  			})
    48  		})
    49  
    50  		Context("with --succinct=false", func() {
    51  			It("should not be in succinct mode", func() {
    52  				session := startGinkgo(fm.TmpDir, "--no-color", "--succinct=false", "passing_ginkgo_tests", "more_ginkgo_tests")
    53  				Eventually(session).Should(gexec.Exit(0))
    54  				output := session.Out.Contents()
    55  
    56  				Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
    57  				Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
    58  			})
    59  		})
    60  
    61  		Context("with -v", func() {
    62  			It("should not be in succinct mode, but should be verbose", func() {
    63  				session := startGinkgo(fm.TmpDir, "--no-color", "-v", "passing_ginkgo_tests", "more_ginkgo_tests")
    64  				Eventually(session).Should(gexec.Exit(0))
    65  				output := session.Out.Contents()
    66  
    67  				Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
    68  				Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
    69  				Ω(output).Should(ContainSubstring("should proxy strings"))
    70  				Ω(output).Should(ContainSubstring("should always pass"))
    71  			})
    72  
    73  			It("should emit output from Bys", func() {
    74  				session := startGinkgo(fm.PathTo("passing_ginkgo_tests"), "--no-color", "-v")
    75  				Eventually(session).Should(gexec.Exit(0))
    76  				output := session.Out.Contents()
    77  
    78  				Ω(output).Should(ContainSubstring("emitting one By"))
    79  				Ω(output).Should(ContainSubstring("emitting another By"))
    80  			})
    81  
    82  			It("doesn't trigger the race detector", func() {
    83  				session := startGinkgo(fm.PathTo("passing_ginkgo_tests"), "--no-color", "-v", "-race")
    84  				Eventually(session).Should(gexec.Exit(0))
    85  				output := session.Out.Contents()
    86  
    87  				Ω(output).Should(ContainSubstring("avoiding the race detector"))
    88  			})
    89  		})
    90  
    91  		Context("with -vv", func() {
    92  			It("should not be in succinct mode, but should be verbose", func() {
    93  				session := startGinkgo(fm.TmpDir, "--no-color", "-vv", "passing_ginkgo_tests", "more_ginkgo_tests")
    94  				Eventually(session).Should(gexec.Exit(0))
    95  				output := session.Out.Contents()
    96  
    97  				Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
    98  				Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
    99  				Ω(output).Should(ContainSubstring("should proxy strings"))
   100  				Ω(output).Should(ContainSubstring("should always pass"))
   101  			})
   102  
   103  			It("should emit output from Bys", func() {
   104  				session := startGinkgo(fm.PathTo("passing_ginkgo_tests"), "--no-color", "-vv")
   105  				Eventually(session).Should(gexec.Exit(0))
   106  				output := session.Out.Contents()
   107  
   108  				Ω(output).Should(ContainSubstring("emitting one By"))
   109  				Ω(output).Should(ContainSubstring("emitting another By"))
   110  			})
   111  		})
   112  	})
   113  })
   114  

View as plain text