gomega
ginkgo
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
gomega
-
Writing tests for a Kubernetes Operator
Gomega: is a test assertion library, a vital dependency on Ginkgo.
- Quick tip: Easy test assertions with Go generics
-
Learning Go by examples: part 6 - Create a gRPC app in Go
Gomega is a Go library that allows you to make assertions. In our example, we check if what we got is null, not null, or equal to an exact value, but the gomega library is much richer than that.
-
Tips to prevent adoption of your API
Depends on the API and how much testing you need. You want to test your code, not the API's availability or correctness.
But it can be as easy as using a fake http library and mocking the responses, or using a httptest server: https://onsi.github.io/gomega/#ghttp-testing-http-clients
If the API is complicated and you have to write your own fake server, that might not make sense for small projects.
- fluentassert - a prototype of yet another assertion library
-
Go generics beyond the playground
If we do the count, we gather that subtest appear to solve five out of the six problems we identified with the assert library. At this point though, it's important to note that at the time when the assert package was designed, the sub-test feature in Go did not yet exist. Therefore it would have been impossible for that library to embed it into it's design. This is also true for when Gomega and Ginko where designed. If these test frameworks where created now, then most likely some parts of their design would have been done differently. What I am trying to say is that with even the slightest change in the Go language and standard library, completely new ways of designing programs become possible. Especially for new packages without any legacy use-cases to consider. And this brings us to generics.
ginkgo
-
Mastering Golang Debugging in Emacs
Debug both standard applications and Ginkgo tests (this is what I'm using at the moment 🤷)
-
Go-DOM - 1st major milestone
Let's explore a simple test, as it looks now in the code base (the code uses Ginkgo and Gomega, a somewhat overlooked combination IMHO)
-
Functional Programming in Go
Take a look at the Ginkgo testing framework to see the horrors of shoe horning FP into Go
https://onsi.github.io/ginkgo/#writing-specs
-
Show HN: Gomponents, HTML components in pure Go
It's the same with the Ginkgo testing library: "After the package books_test declaration we import the ginkgo and gomega packages into the test's top-level namespace by performing a . dot-import. Since Ginkgo and Gomega are DSLs this makes the tests more natural to read."
https://onsi.github.io/ginkgo/
-
Leverage Your Test Suite With testcontainers-go & docker-compose
The ginkgo testing framework helps us in building the test suite. It's entirely written in Go. Furthermore, it provides a CLI utility to set up and run the tests. Since we will use it later, let's download it from here. You can download it in two ways:
-
Writing tests for a Kubernetes Operator
Ginkgo: a testing framework based on the concept of ‌"Behavior Driven Development" (BDD)
-
We moved our Cloud operations to a Kubernetes Operator
We were also able to leverage Ginkgo's parallel testing runtime to run our integration tests on multiple concurrent processes. This provided multiple benefits: we could run our entire integration test suite in under 10 minutes and also reuse the same suite to load test the operator in a production-like environment. Using these tests, we were able to identify hot spots in the code that needed further optimization and experimented with ways to save API calls to ease the load on our own Kubernetes API server while also staying under various AWS rate limits. It was only after running these tests over and over again that I felt confident enough to deploy the operator to our dev and prod clusters.
-
Recommendations for Learning Test-Driven Development (TDD) in Go?
A bit off-topic, but i really like the ginkgo BDD framework
-
Start test names with “should” (2020)
You obviously are not familiar with the third circle of golang continuous integration hell that is ginkgo+gomega:
https://onsi.github.io/ginkgo/#adding-specs-to-a-suite
It’s actually worse than that example suggests. Stuff like Expect(“type safety”).ShouldBe(GreaterThan(13)) throws runtime errors.
The semantics of parallel test runs weren’t defined anywhere the last time I checked.
Anyway, you’ll be thinking back fondly to the days of TestShouldReplaceChildrenWhenUpdatingInstance because now you need to write nested function calls like:
Context(“instances”, func …)
Describe(“that are being updated”, …)
Expect(“should replace children”, …)
And to invoke that from the command line, you need to write a regex against whatever undocumented and unprinted string it internally concatenates together to uniquely describe the test.
Also, they dump color codes to stdout without checking that they are writing to a terminal, so there will be line noise all over whatever automated test logs you produce, or if you pipe stdout to a file.
-
ginkgo integration with jira/elasticsearch/webex/slack
If you are using Ginkgo for your e2e, this library might of help.
What are some alternatives?
Testify - A toolkit with common assertions and mocks that plays nicely with the standard library
GoConvey - Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.
assert - :exclamation:Basic Assertion Library used along side native go testing, with building blocks for custom assertions
godog - Cucumber for golang
goblin - Minimal and Beautiful Go testing framework
httpexpect - End-to-end HTTP and REST API testing for Go.
gocheck - Rich testing for the Go language