Skip to content

Golang Unit Testing: Brief Guide and Best Practices #103

@matthawkins90

Description

@matthawkins90

I'm trying to teach myself Go.

Unit tests are highly valued for these projects. Unit tests are also a great way for new contributors to get familiar with a project, and can also serve as a form of documentation for how code works.

I think it would be a good idea to have a basic guide and "best practices" in the Contributing section of the dev docs, just to start collecting that knowledge there.

I'm thinking about having sections like:

  • Example of how to run tests that are already there
  • Example of how to run a specific test
  • Best practices for writing good tests:
    • Table-driven tests
    • Subtests
  • Measuring code coverage
  • Finding areas of the codebase that need unit tests

I'm definitely not an expert on any of these topics, but I want to start aggregating information into a guide. I would welcome any tips or examples to follow from more experienced devs here!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions