Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testcontainers for your Golang projects

Testcontainers for your Golang projects

Quick overview of the Testcontainers for integration testing in your Golang projects, with WireMock as an example

Avatar for Oleg Nenashev

Oleg Nenashev PRO

June 17, 2025
Tweet

Resources

More Decks by Oleg Nenashev

Other Decks in Technology

Transcript

  1. Oleg Nenashev @oleg_nenashev oleg-nenashev Community builder Developer Tools Hacker Testcontainers

    Champion Cloud Native Suisse Romande #RussiansAgainstPutin #StandWithUkraine
  2. Integration Testing • Multiple technology stacks and toolchains • Many

    teams involved • Sacred knowledge • [Almost] always too late
  3. Build Unit tests Publish Reports Integration tests Publish Reports NOW

    “Shift Left” Fast integrations tests are critical
  4. Ways to do integration testing 1. Testing against Production/Staging Slow

    Fast Nope Accu- rate 2. Testing against a simplified/containerized instance (e.g. Testcontainers) 4. Mocking at the code level (e.g. GoMock) 3. Mocking at the API provider level (e.g. Microcks, WireMock)
  5. Ways to do integration testing 1. Testing against Production/Staging Slow

    Fast Nope Accu- rate 2. Testing against a simplified/containerized instance (e.g. Testcontainers) 4. Mocking at the code level (e.g. GoMock) 3. Mocking at the API provider level (e.g. Microcks, WireMock)
  6. wiremock.org/docs/stubbing IF (request_url) THEN (response) * * it gets MUCH

    more complex WireMock Config JSON: Client library response request Client App Mock API Server HTTP/2 API Mocking 101
  7. API Mocking Tools Main implementation in Java Native lib, Docker

    images and Testcontainers modules Support for GraalVM Rich Ecosystem Sandbox CNCF Project Golang / Microservice arch Docker image, Testcontainers module, All-in K8s Charts Less Rich Ecosystem
  8. WireMock for Go Testcontainers Module REST API Client Go test

    integrations go.wiremock.org github.com/wiremock/wiremock-testcontainers-go
  9. DEMO - API Mocking with WireMock • Golang, Testcontainers, WireMock

    Module • Sources location: github.com/wiremock/wiremock-testcontain ers-go/tree/main/examples/quickstart
  10. Takeaways 31 • Shift left the integration testing • API

    Mocking / abstraction are great… when used right • There is no silver bullet • WireMock and Testcontainers address their own use-cases • They work well together!
  11. Learn More at Oleg Nenashev - Workshop Mocks as Code.

    Modeling AWS service providers with Testcontainers, WireMock and Localstack LocalStack