Skip to content

ctx42/testing

Repository files navigation

gopher.png

Go Report Card GoDoc Tests


With zero external dependencies module provides:

  • assert (72 hand-picked assertion functions), mock and mocker packages.
  • Golden file testing helpers in goldy package.
  • Assortment of helpers in kit package.
  • Configurable any type string dumper in dump package.
  • Build your own assertions with ease using check package.
  • Test your test helpers with tester package.

Goal

Provide a comprehensive suite of tools designed to make testing more efficient, enjoyable to write, and integral to the development process.

Whether you're a seasoned tester or just starting out, tools in this module are being crafted to meet your needs, providing a solid foundation for ensuring code reliability in projects of all sizes.

Simplicity and Usability

At the heart of the module lies a commitment to minimalism and an exceptional developer experience (DX). By maintaining zero external dependencies, the framework stays lightweight and fast, free from the potential complexities and conflicts that third-party modules can introduce. Our documentation is being carefully designed to be thorough, clear, and packed with practical examples, empowering you to master the module with ease. Expect a great DX with features like a fluent, chainable API, descriptive error messages for quick debugging, all tailored to streamline your testing workflow.

Modular and Extensible Design

The testing module is built as a collection of modular, laser-focused packages, each targeting a specific aspect of testing. For instance, you might leverage the assert package for assertions, the mock and mocker packages for test doubles, or the kit package to keep your tests readable and minimalistic. The modularity lets you customize your testing setup to fit your project’s exact needs, avoiding unnecessary overhead. Beyond customization, the extensible architecture invites you to create your own test helpers.

Installation

To install CTX42 Testing Module, use go get:

go get github.com/ctx42/testing

This will make all the package modules available to you.

Packages

Main Packages

Packages used in test cases.

  • Package assert provides assertion toolkit.
  • Package check provides equality toolkit used by assert package.
  • Package goldy provides basic golden file support.
  • Package kit provides all sorts of test helpers that are not assertions.
  • Package mock provides primitives for writing interface mocks.
  • Package mocker provides an interface mock generator.
  • Package must provide basic test helpers which panic on error.

Supporting Packages

Packages are used to create custom checks, assertions, and helpers.

  • Package dump provides a configurable renderer of any type to a string.
  • Package notice helps to create nicely formatted assertion messages.
  • Package tester provides facilities to test Test Helpers.

Click on the package link to see its README.md file with documentation. Also, most of the packages contain examples_test.go file with usage examples.

Blog posts

I’ve written several blog posts tied to this repository. If you’re curious about the behind-the-scenes details of how this package is coming together, check them out and share your thoughts — I’d love to hear what you think! Any feedback is greatly appreciated.

About

Go Testing Module with mocking, mock generation & golden files support.

Topics

Resources

License

Stars

Watchers

Forks