Unit testing conventions #168
Replies: 5 comments 1 reply
-
my 2 cents:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Also not a fan of Ginkgo. Would not set a hard rule requiring or prohibiting table tests. Sometimes it makes sense; sometimes it doesn't. Would recommend using testify for simple assertions to save some typing. Would recommend against too many shared helper functions that set up CRs and whatnot - it's easy to forget/be unaware of what they do exactly... |
Beta Was this translation helpful? Give feedback.
-
ok - I'm going to close this discussion. I'm opening a ticket for us to document our unit testing guidelines. I believe what Andy has up here is a good place to start. I'll also create some ticket for refactoring the current unit tests from ginkgo to go test. |
Beta Was this translation helpful? Give feedback.
-
I agree that keeping one standard is better than having multiple styles (+1). I’d like to just clarify a point that may be misunderstood:
This is not true. A However, you can structure your suite within the same file as the tests, similar to standard Go testing, if you prefer. The Examplepackage mypackage_test
import (
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestMyCode(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "MyCode Suite")
}
var _ = Describe("MyCode", func() {
It("should perform action A", func() {
Expect(true).To(BeTrue())
})
It("should perform action B", func() {
Expect(true).To(BeTrue())
})
}) |
Beta Was this translation helpful? Give feedback.
-
A recent discussion in #142 raised a couple of questions around what our unit testing conventions ought to be:
For the sake of consistency, I'm putting this out there to our community so we can establish some best practices and conventions. IMHO:
Beta Was this translation helpful? Give feedback.
All reactions