Spike: Migrate from Ginkgo to Testify (standard go testing)
Summary
Ginkgo has been the primary testing framework for our Kubernetes operator, since it comes with the kubebuilder
. While Ginkgo provides powerful BDD-style testing capabilities, the complexity and verbosity of the test code have become a concern, and it is un-easy to debug a test. Testify, with its simpler and more straightforward syntax, is widely adopted.
Benefits of Testify (standard go testing)
- Simpler Syntax: Testify's syntax is more intuitive and concise, making test cases easier to write and understand. More natural to Go developers.
- Improved Readability: Testify's assertion library provides clear and readable assertions, reducing cognitive load for developers.
- Easy Integration: Testify integrates seamlessly with the Go testing framework, allowing us to leverage Go's standard tools and features.
- Active Maintenance: Testify is actively maintained and widely adopted in the Go community, ensuring robust support and continuous improvements.
- More flexibility: Testify, by default only provides a wide range of assertion functions and testing utilities, giving us more flexibility in writing test cases. They also have a mocking library, a extendable suite package similiar to Ginkgo. One major complain about Ginkgo is that it's too opinionated and doesn't provide much flexibility, e.g. assertion during the declaration of the table params.
A survey on other operator projects
I randomly picked a few well-known operator projects, a significant number of projects dropped Ginkgo in favor of the standard Go testing framework. Here are some examples:
-
https://github.dev/argoproj-labs/argocd-operator/blob/master/go.mod (you see the ginkgo package in
go.mod
, but they are not using it) - https://github.com/open-telemetry/opentelemetry-operator/blob/main/go.mod
- https://github.com/prometheus-operator/prometheus-operator/blob/main/go.mod
- https://github.com/elastic/cloud-on-k8s/blob/main/go.mod
- https://github.com/cert-manager/cert-manager/blob/master/go.mod
- https://github.com/minio/operator/blob/master/go.mod
Success criteria
-
TBD
Edited by Lucas Li