ginkgo
ginkgo copied to clipboard
could not log in Eventually with fmt.Fprintf(GinkgoWriter)
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.
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
).
i did use ginkgo -v, and it still not output streamed.
what i expect is it should print "sth wrong" each 2s.