Russ Cox: Go Testing by Example

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. gobyexample

    Go by Example

    Some similar resources I like:

    "Learn Go with Tests" book: https://quii.gitbook.io/learn-go-with-tests

    "Go by Example": https://gobyexample.com/

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. testy

    typesafe (generics) helpers for better golang tests

    Agreed with most of this but I’m skeptical of the rsc.io/script dsl approach. I’ll try it, though, because Russ is often right.

    shameless advert: do you wish testify was implemented with generics and go-cmp, and had a more understandable surface area? Check out my small zero-dep library, Testy https://github.com/peterldowns/testy

    shameless advert: do you want to write tests against your postgres database, but each new test adds seconds to your test suite? Check out pgtestdb, the marginal cost of each test is measured in tens of milliseconds, and each test gets a unique and isolated postgres instance — with all your migrations applied. https://github.com/peterldowns/pgtestdb

  4. pgtestdb

    quickly run tests in their own temporary, isolated, postgres databases

    Agreed with most of this but I’m skeptical of the rsc.io/script dsl approach. I’ll try it, though, because Russ is often right.

    shameless advert: do you wish testify was implemented with generics and go-cmp, and had a more understandable surface area? Check out my small zero-dep library, Testy https://github.com/peterldowns/testy

    shameless advert: do you want to write tests against your postgres database, but each new test adds seconds to your test suite? Check out pgtestdb, the marginal cost of each test is measured in tens of milliseconds, and each test gets a unique and isolated postgres instance — with all your migrations applied. https://github.com/peterldowns/pgtestdb

  5. gotests

    Automatically generate Go test boilerplate from your source code.

    A huge time-saver for me when generating table-driven test boilerplate in Go has been using gotests[0] to generate the template.

    If you use VSCode with the Go extension it's already available there as a command "Go: Generate Unit Tests for Function/Package".

    [0] https://github.com/cweill/gotests

  6. dotfiles

    My dotfiles, managed with https://chezmoi.io. (by twpayne)

    chezmoi (<https://chezmoi.io> or <https://github.com/twpayne/chezmoi>) has a couple dozen txtar tests. They are both amazing and completely frustrating to use, but I don't think that there would be a better way to test most of what chezmoi does without them.

    Tom Payne (the creator and primary developer of chezmoi) has added some extra commands to the txtar context which makes things easier for certain classes of testing.

  7. chezmoi

    Manage your dotfiles across multiple diverse machines, securely.

    chezmoi (<https://chezmoi.io> or <https://github.com/twpayne/chezmoi>) has a couple dozen txtar tests. They are both amazing and completely frustrating to use, but I don't think that there would be a better way to test most of what chezmoi does without them.

    Tom Payne (the creator and primary developer of chezmoi) has added some extra commands to the txtar context which makes things easier for certain classes of testing.

  8. Txtar

    Swift implementation of a txtar parser and formatter.

  9. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  10. skeema

    Declarative pure-SQL schema management for MySQL and MariaDB

    Using tmpfs for MySQL/MariaDB's data directory helps tremendously. If you're using Docker natively on Linux, use `docker run --tmpfs /var/lib/mysql ...` and that'll do the trick. Only downside is each container restart is slightly slower due to having to re-init the database instance from scratch.

    Tuning the database server settings can help a lot too. You can add overrides to the very end of your `docker run` command-line, so that they get sent as command-line args to the database server. For example, use --skip-performance-schema to avoid the overhead of performance_schema if you don't need it in your test/CI environment.

    For MySQL 8 in particular, I've found a few additional options help quite a lot: --skip-innodb-adaptive-hash-index --innodb-log-writer-threads=off --skip-log-bin

    A lot of other options may be workload-specific. My product Skeema [1] can optionally use ephemeral containerized databases [2] for testing DDL and linting database objects, so the workload is very DDL-heavy, which means the settings can be tuned pretty differently than a typical DML-based workload.

    [1] https://github.com/skeema/skeema/

    [2] https://www.skeema.io/docs/options/#workspace

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Why elixir over Golang

    10 projects | /r/elixir | 29 May 2023
  • Using SQLC in project how do I mock database Calls with it for unit testing?

    3 projects | /r/golang | 22 Oct 2022
  • How to mock database calls

    4 projects | /r/golang | 27 Aug 2022
  • Mocking database or use a test database

    5 projects | /r/golang | 18 Apr 2022
  • I share my authentication server.

    18 projects | /r/golang | 20 Dec 2021

Did you know that Go is
the 4th most popular programming language
based on number of references?