About time: how to unit test code that depends on time

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

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

    Let your Python tests travel through time

  • * in C++.

    On Python, just use freezegun to inject controllable timestamps in response to calls to time methods.

    https://github.com/spulec/freezegun

  • timecop

    A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.

  • The Ruby equivalent is Timecop

    https://github.com/travisjeffery/timecop

    Dynamic languages have the advantage to be able to rewrite the standard library classes at runtime.

  • 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
  • time-machine

    Travel through time in your tests.

  • Freezegun is pretty much unmaintained. You want time-machine https://github.com/adamchainz/time-machine

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