{"id":13682768,"url":"https://github.com/typelevel/cats-effect-testing","last_synced_at":"2025-05-15T23:08:18.525Z","repository":{"id":37104789,"uuid":"193926623","full_name":"typelevel/cats-effect-testing","owner":"typelevel","description":"Integration between cats-effect and test frameworks","archived":false,"fork":false,"pushed_at":"2025-04-08T00:21:44.000Z","size":793,"stargazers_count":189,"open_issues_count":24,"forks_count":42,"subscribers_count":15,"default_branch":"series/1.x","last_synced_at":"2025-05-07T09:38:43.539Z","etag":null,"topics":["cats","cats-effect","minitest","scala","scalatest","specs2","utest"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/typelevel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-06-26T14:59:32.000Z","updated_at":"2025-03-23T22:34:21.000Z","dependencies_parsed_at":"2023-02-13T18:32:02.674Z","dependency_job_id":"a176f37a-20d0-40af-80f0-0a4996d945a6","html_url":"https://github.com/typelevel/cats-effect-testing","commit_stats":{"total_commits":431,"total_committers":29,"mean_commits":"14.862068965517242","dds":0.6566125290023201,"last_synced_commit":"47b0c0cea2f20beb33966bf4a0cdd882ae43f1bb"},"previous_names":["djspiewak/cats-effect-testing"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fcats-effect-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fcats-effect-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fcats-effect-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typelevel%2Fcats-effect-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typelevel","download_url":"https://codeload.github.com/typelevel/cats-effect-testing/tar.gz/refs/heads/series/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436949,"owners_count":22070947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cats","cats-effect","minitest","scala","scalatest","specs2","utest"],"created_at":"2024-08-02T13:01:52.884Z","updated_at":"2025-05-15T23:08:12.152Z","avatar_url":"https://github.com/typelevel.png","language":"Scala","funding_links":[],"categories":["Scala"],"sub_categories":[],"readme":"# cats-effect-testing\n\nA quickie little utility which makes it easier to write tests using [specs2](https://specs2.org) (mutable or functional), [scalatest](http://scalatest.org), [µTest](https://github.com/lihaoyi/utest) or [minitest](https://github.com/monix/minitest) where the examples are effectful within `cats.effect.IO`.\n\n## Specs2\n\n```scala\nimport cats.effect.IO\nimport cats.effect.testing.specs2.CatsEffect\nimport org.specs2.mutable.Specification\n\n// for some reason, only class works here; object will not be detected by sbt\nclass ExampleSpec extends Specification with CatsEffect {\n  \"examples\" should {\n    \"do the things\" in IO {\n      true must beTrue\n    }\n  }\n}\n```\n\nThe above compiles and runs exactly as you would expect.\n\nBy default, tests run with a 10 second timeout. If you wish to override this, simply override the inherited `Timeout` val:\n\n```scala\noverride val Timeout = 5.seconds\n```\n\nIf you need an `ExecutionContext`, one is available in the `executionContext` val.\n\nAnd if you need to share Cats Effect's Resource between test examples you can extend `CatsResource`, like so:\n\n```scala\nimport cats.effect.{IO, Ref, Resource}\nimport org.specs2.mutable.SpecificationLike\n\nclass CatsResourceSpecs extends CatsResource[IO, Ref[IO, Int]] with SpecificationLike {\n  sequential\n\n  val resource: Resource[IO, Ref[IO, Int]] =\n    Resource.make(Ref[IO].of(0))(_.set(Int.MinValue))\n\n  \"cats resource support\" should {\n    \"run a resource modification\" in withResource { ref =\u003e\n      ref.modify{ a =\u003e\n        (a + 1, a)\n      }.map(\n        _ must_=== 0\n      )\n    }\n\n    \"be shared between tests\" in withResource { ref =\u003e\n      ref.modify{ a =\u003e\n        (a + 1, a)\n      }.map(\n        _ must_=== 1\n      )\n    }\n  }\n}\n```\n\nThe Resource is acquired before the tests are run and released afterwards. A more realistic example would be to share a Resource that takes a long time to start up.\n\n### Usage\n\n```sbt\nlibraryDependencies += \"org.typelevel\" %% \"cats-effect-testing-specs2\" % \"\u003cversion\u003e\" % Test\n```\n\nPublished for Scala 3.1+, 2.13, 2.12, as well as ScalaJS 1.7+. Depends on Cats Effect 3.1+ and Specs2 4.13.x. Specs2 5.0 is not yet supported.\n\nEarly versions (`0.x.y`) were published under the `com.codecommit` groupId.\n\n## ScalaTest\n\n```scala\nimport cats.effect._\nimport cats.effect.testing.scalatest.AsyncIOSpec\nimport org.scalatest.matchers.should.Matchers\nimport org.scalatest.freespec.AsyncFreeSpec\n\nclass MySpec extends AsyncFreeSpec with AsyncIOSpec with Matchers {\n\n  \"My Code \" - {\n    \"works\" in {\n      IO(1).asserting(_ shouldBe 1)\n    }\n}\n\n```\n### Usage\n\n```sbt\nlibraryDependencies += \"org.typelevel\" %% \"cats-effect-testing-scalatest\" % \"\u003cversion\u003e\" % Test\n```\n\nPublished for Scala 3.1+, 2.13, 2.12, as well as ScalaJS 1.7.x. Depends on Cats Effect 3.1+ and scalatest 3.2.6.\n\nEarly versions (`0.x.y`) were published under the `com.codecommit` groupId.\n\n## µTest\n\n```scala\nimport scala.concurrent.duration._\nimport utest._\nimport cats.syntax.all._\nimport cats.effect.IO\nimport cats.effect.testing.utest.IOTestSuite\n\nobject SimpleSuite extends IOTestSuite {\n  override val timeout = 1.second // Default timeout is 10 seconds\n\n  val tests = Tests {\n    test(\"do the thing\") {\n      IO(assert(true))\n    }\n  }\n}\n\n```\n\n### Usage\n\n```sbt\nlibraryDependencies += \"org.typelevel\" %% \"cats-effect-testing-utest\" % \"\u003cversion\u003e\" % Test\n```\n\nPublished for Scala 3.1+, 2.13, 2.12, as well as ScalaJS 1.7.x. Depends on Cats Effect 3.1+ and µTest 0.7.9.\n\nEarly versions (`0.x.y`) were published under the `com.codecommit` groupId.\n\n## Minitest\n\nMinitest is very similar to uTest, but being strongly typed, there's no need to support\nnon-IO tests\n\n```scala\nimport scala.concurrent.duration._\nimport cats.syntax.all._\nimport cats.effect.IO\nimport cats.effect.testing.minitest.IOTestSuite\n\nobject SimpleSuite extends IOTestSuite {\n  override val timeout = 1.second // Default timeout is 10 seconds\n\n  test(\"do the thing\") {\n    IO(assert(true))\n  }\n}\n```\n\n### Usage\n\n```sbt\nlibraryDependencies += \"org.typelevel\" %% \"cats-effect-testing-minitest\" % \"\u003cversion\u003e\" % Test\n```\n\nPublished for Scala 3.1+, 2.13, 2.12, as well as ScalaJS 1.7.x. Depends on Cats Effect 3.1+ and minitest 2.9.5.\n\nEarly versions (`0.x.y`) were published under the `com.codecommit` groupId.\n\n## Similar projects\n\n### scalacheck-effect\n\n[scalacheck-effect](https://github.com/typelevel/scalacheck-effect) is a library that extends the functionality of [ScalaCheck](https://scalacheck.org) to support \"effectful\" properties. An effectful property is one that evaluates each sample in some type constructor `F[_]`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypelevel%2Fcats-effect-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypelevel%2Fcats-effect-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypelevel%2Fcats-effect-testing/lists"}