Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could not log in Eventually with fmt.Fprintf(GinkgoWriter) #1388

Open
woodgear opened this issue Apr 17, 2024 · 3 comments
Open

could not log in Eventually with fmt.Fprintf(GinkgoWriter) #1388

woodgear opened this issue Apr 17, 2024 · 3 comments

Comments

@woodgear
Copy link

package books_test

import (
	"fmt"
	"testing"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

var _ = Describe("Books", func() {
	It("should be a novel", func() {
		fmt.Fprintf(GinkgoWriter, "here\n")
		Eventually(func(g Gomega) {
			fmt.Println("println here")
			fmt.Fprintf(GinkgoWriter, "in eventually here\n")
			g.Expect(true).To(BeFalse(), "sth wrong")
		}, "10m", "2s").Should(Succeed())
	})
})

func TestBooks(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Books Suite")
}

the output is

=== RUN   TestBooks
Running Suite: Books Suite - /home/cong/sm/tmp/tgg
==================================================
Random Seed: 1713324181

Will run 1 of 1 specs
println here
println here
println here
println here
println here
println here

notice that "sth wrong" or "in eventually here" does not show out.

@onsi
Copy link
Owner

onsi commented Apr 17, 2024

The GinkgoWriter output will only show when the test finally fails. You could try with ginkgo -v to see the output streamed immediately (though this only works when running in series i.e. not with ginkgo -p).

@woodgear
Copy link
Author

i did use ginkgo -v, and it still not output streamed.
图片

@woodgear
Copy link
Author

what i expect is it should print "sth wrong" each 2s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants