Stop requiring only one assertion per unit test: Multiple assertions are fine

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

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • pytest-parametrize-cases

    Nicer way to do parametrized tests

  • ts-pattern

    🎨 The exhaustive Pattern Matching library for TypeScript, with smart type inference.

  • I'm not aware of any related to testing, but perhaps you could use something like this in tandem with some tests to pull it off?

    https://github.com/gvergnaud/ts-pattern

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • just-tap

    Discontinued A simple tap test runner that can be used by any javascript interpreter.

  • Yup, it's why I built `just-tap` [1] which trys to minimise as much magic that a lot of these frameworks try to "help" you with.

    1. https://github.com/markwylde/just-tap

  • unquote

    Write F# unit test assertions as quoted expressions, get step-by-step failure messages for free

  • JSONAssert

    Write JSON unit tests in less code. Great for testing REST interfaces.

  • This can be improved, it'd be worth Googling for a better solution than what you have.

    https://github.com/skyscreamer/JSONassert seems decent.

    but it can be done from scratch in a few hours (I'd recommend this if you have 'standardized' fields which you may want to ignore):

    1) Move to a matcher library for assertions (Hamcrest is decent), and abstract `toJSON` into the a matcher, rather on the input.

    This would change the assertion from:

    `assertEquals(toJson(someObject), giantJsonBlobFromADifferentFile)`

    to:

    `assertThat(someObject, jsonEqual(giantJsonBlobFromADifferentFile))`

    The difference here is subtle: it allows `jsonEqual` to control the formatting of the test failure output, so on a failure you can:

    * convert both of the strings back to JSON

    * perform a diff, and provide the diff in the test output.

    Decent blog post on the topic: https://veskoiliev.com/use-custom-hamcrest-matchers-to-level...

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
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