venom
testcontainers-go
Our great sponsors
venom | testcontainers-go | |
---|---|---|
6 | 18 | |
974 | 3,040 | |
2.9% | 7.9% | |
7.2 | 9.7 | |
1 day ago | 7 days ago | |
Go | Go | |
Apache License 2.0 | MIT License |
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.
venom
-
Ask HN: What's your favorite software testing framework and why?
You can also load fixtures in database directly, work with Kafka queues both as a producer (e.g. write an event to a Kafka queue, wait a few seconds and see that it was consumed by the service you test, and that some side effects can be observed) or as a consumer (e.g. make sure after an HTTP call, an event was correctly pushed to a queue), or even read a mailbox in IMAP to check that your service correctly send an email.
It's a bit rough on the edges sometimes, but I'd never go back on writing integration tests directly in my programming language. Declarative is the way to go.
[1]: https://github.com/ovh/venom
-
Easy Integration Testing with Venom!
To write and run our integration tests, we'll use Venom. Venom is a tool created and made open-source by OVHcloud: https://github.com/ovh/venom
- Venom: Manage and run your integration tests with efficiency
-
Show HN: Step CI โ API Testing and Monitoring Made Simple
From my experience, generated tests are worthless for anything more serious than smoke tests. I prefer working with no tests than automated tests, I feel they give you a false sense of confidence.
The Step CI engine itself looks good though. It looks like a cleaner, but less powerful version of a tool (open source, build in-house) we used when I worked at OVHcloud, Venom: https://github.com/ovh/venom
Here's an example test file for the HTTP executor of Venom: https://github.com/ovh/venom/blob/master/tests/http.yml it's very close to Step CI format.
I'd still use Venom because it's way more powerful (you have DB executors for example, so after executing a POST request you can actually check in DB that you have what you expect) and I prefer focusing on actually writing integration tests instead of generating them.
Maybe this post sounds harsh (I feel it as I write it because I have strong feelings against test generation) but I think your approach is a good one for actually writing automated tests. Testing APIs declaratively like this has a great benefit: your tests work on an interface. You can migrate your API to a whole new stack and your tests remain the same. I did it multiple time at OVHcloud: one time migrating a huge API from a Go router to another (Gin->Echo), and another time migrating public APIs from a legacy, in-house Perl engine to a Go server.
-
Debugging with GDB
I still struggle with GDB but my excuse is that I seldom use it.
When I was studying reverse engineering though, I came across a really cool kit (which I've yet to find an alternative for lldb, which would be nice given: rust)
I'd recommend checking it out, if for no other reason than it makes a lot of things really obvious (like watching what value lives in which register).
https://github.com/hugsy/gef
LLDB's closest alternative to this is called Venom, but it's not the same at all. https://github.com/ovh/venom
-
Do you write integration tests in go?
We incorporated [Venom](https://github.com/ovh/venom) into our workflow. It's great for initiating and managing a suite of yaml based tests. It didn't work out of the box for us due to the heavily asynchronous nature of our system, but after a few additions, it has helped my team greatly. We were often afraid to make large changes to critical pieces of the system since a full regression test could take a week or so to check everything. Now it takes an hour.
testcontainers-go
-
Using test helpers in Go
Let's first look at the original version of the test, in this case, an end-to-end, using testcontainers.
-
Run and test DynamoDB applications locally using Docker and Testcontainers
It supports multiple languages (including Go!) and databases (also messaging infrastructure etc.) - All you need is Docker. Testcontainers for Go makes it simple to programmatically create and clean up container-based dependencies for automated integration/smoke tests. You can define test dependencies as code, run tests and delete the containers once done.
-
๐ Effortless Integration Tests with Testcontainers in Golang ๐งช
Testcontainers Go Documentation
-
go-ecommerce-microservices: A practical e-commerce microservices, built with cqrs, event sourcing, vertical slice architecture, event-driven architecture.
Some of the features: - โ Using Vertical Slice Architecture as a high level architecture - โ Using Event Driven Architecture on top of RabbitMQ Message Broker with a custom [Event Bus](pkg/messaging/bus/) - โ Using Event Sourcing in Audit Based services like [Orders Service](services/orders/) - โ Using CQRS Pattern and Mediator Patternon top of Go-MediatR library - โ Using Dependency Injection and Inversion of Controlon top of uber-go/fx library - โ Using RESTFul api with Echo framework and using swagger with swaggo/swag library - โ Using Postgres and EventStoreDB to write databases with fully supports transactions(ACID) - โ Using MongoDB and Elastic Search for read databases (NOSQL) - โ Using OpenTelemetry for collection Distributed Tracing with using Jaeger and Zipkin - โ Using OpenTelemetry for collection Metrics with using Prometheus and Grafana - โ Using Unit Test for testing small units with mocking dependent classes and using Mockery for mocking dependencies - โ Using End2End Test and Integration Test for testing features with all of their real dependeinces using docker containers (cleanup tests) and testcontainers-go library
- How to start a Go project in 2023
-
Questions about Interfacing for Unit-Tests
For example, you could take a look at this open-source project that helps you spawn docker containers as part of your test setup enabling you to execute queries to a local database.
-
How to Work with SQL Databases in Go
Using something like TestContainers to spin up a DB for testing has been my best experience. Any mocks leave too much room for error imo
-
Different SQL drivers for test and production
I highly recommend testcontainers for this.
-
Go API Project Set-Up
The next block in .gitlab-ci.yml is the services block. Since our tests use testcontainers package and we're pushing a docker container onto Dockerhub, we will need to specify a services block next. Services will enable our pipeline to leverage Docker-in-Docker DinD.
- Do you test your API, repositories, & services together (e.g., e2e) or separately?
What are some alternatives?
godog - Cucumber for golang
dockertest - Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work.
otj-pg-embedded - Java embedded PostgreSQL component for testing
stepci - Automated API Testing and Quality Assurance
testcontainers-dotnet - A library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions.
gotestfmt - go test output for humans
localstripe - A fake but stateful Stripe server that you can run locally, for testing purposes.
gotestfmt - go test output for humans
integresql - IntegreSQL manages isolated PostgreSQL databases for your integration tests.
go-txdb - Immutable transaction isolated sql driver for golang
testcontainers-python - Testcontainers is a Python library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.