lundi 22 décembre 2014

Is it possible to emulate Example testing with Gomega?

I have some go tests that I would like to update to use Ginkgo for BDD style testing. The problem is, the server uses stdout and stderr for logging, and many of the tests utilize Go's built in "Example" testing framework as follows:



import (
"fmt"
)

func ExampleConsoleLog() {
fmt.Printf("Testing %d, %d, %d: %s\n", 1, 2, 3, "mike check")

// Output:
// Testing 1, 2, 3: mike check
}


I would like to using Ginkgo and Gomega to assert that these get printed out to the stdout, but there are no built in matchers that I can tell that do this. Gomega does provide a gbytes package, but there is no documentation on how to "attach" a gbytes.Buffer to stdout or stderr. Is there is a custom matcher that I can use for this?


Aucun commentaire:

Enregistrer un commentaire