{"id":22636130,"url":"https://github.com/47degrees/munit-akka","last_synced_at":"2026-03-03T02:31:42.309Z","repository":{"id":65508437,"uuid":"502190169","full_name":"47degrees/munit-akka","owner":"47degrees","description":"MUnit fixtures for testing with Akka Typed","archived":false,"fork":false,"pushed_at":"2022-06-11T00:51:18.000Z","size":16,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T21:11:34.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/47degrees.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-10T21:53:19.000Z","updated_at":"2023-07-27T17:20:49.000Z","dependencies_parsed_at":"2023-01-26T16:25:14.497Z","dependency_job_id":null,"html_url":"https://github.com/47degrees/munit-akka","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/47degrees/munit-akka","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/47degrees%2Fmunit-akka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/47degrees%2Fmunit-akka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/47degrees%2Fmunit-akka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/47degrees%2Fmunit-akka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/47degrees","download_url":"https://codeload.github.com/47degrees/munit-akka/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/47degrees%2Fmunit-akka/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30030829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T00:31:48.536Z","status":"online","status_checked_at":"2026-03-03T02:00:07.650Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-12-09T03:18:24.442Z","updated_at":"2026-03-03T02:31:42.277Z","avatar_url":"https://github.com/47degrees.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MUnit Akka\n![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/dev.rpeters/munit-akka-typed_2.13?label=latest\u0026server=https%3A%2F%2Foss.sonatype.org)\n\nThis is a small, third-party set of fixtures to help get you started using Akka with the MUnit testing library for Scala.\n\n## License\nCopyright 2022 Ryan Peters\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n## Setup\nThis library is published for Scala 2.12, 2.13, and 3.1.x. Add this to your build file if you are using sbt:\n```\n//For Akka Typed\nlibraryDependencies += \"dev.rpeters\" %% \"munit-akka-typed\" % \"\u003ccurrent-version\u003e\" % Test\n\n//For Akka Persistence\nlibraryDependencies += \"dev.rpeters\" %% \"munit-akka-typed-persistence\" % \"\u003ccurrent-version\u003e\" % Test\n```\n\nFixtures are provided in the `munit.akka.typed` and `munit.akka.typed.persistence` directories respectively.\n\n## Usage\nFixtures are provided as single-use so you can enable them on a per-test basis.\nTo use, you can extend the `munit.akka.typed.AkkaTypedFunSuite` trait for Akka Typed support, and the `munit.akka.typed.persistence.AkkaPersistenceTypedFunSuite` trait for Akka Persistence support.\n\n```scala\npackage com.example\n\nimport munit.akka.typed.AkkaTypedFunSuite\nimport com.example.MyBehavior\n\nclass MyTestSuite extends AkkaTypedFunSuite {\n  akkaTestKit.test(\"My Example Test\") { testKit =\u003e\n    //Spawn typed behaviors with your test kit\n    val behavior = testKit.spawn(MyBehavior(\"some-id\"))\n    \n    //Use the test kit as you normally would\n    val probe = testKit.spawnTestProbe[MyBehavior.Reply]()\n\n    behavior ! MyBehavior.Command.Echo(\"hello world!\", replyTo = probe.ref)\n\n    probe.expectMessage(MyBehavior.Reply.EchoReply(\"hello world!\"))\n  }\n}\n```\n\nYou can use your `ActorTestKit` just as [the main documentation describes](https://doc.akka.io/docs/akka/current/typed/testing.html).\n\n## Persistence\n\nThe Akka Persistence support includes not just an `ActorTestKit` but also three other test kits you can opt into to test event-sourced behaviors as well as persistence and snapshotting.\nAll of the test kits provided by `AkkaPersistenceTypedFunSuite` are preconfigured using the internal configuration used in the normal Akka Persistence integrations, so you will automatically get in-memory persistence journaling and snapshotting.\n\n```scala\npackage com.example\n\nimport munit.akka.typed.AkkaTypedFunSuite\nimport com.example.MyBehavior\n\nclass MyPersistenceTestSuite extends AkkaPersistenceTypedFunSuite {\n  //Contains all of the same fixtures as normal Akka Typed\n  akkaTestKit.test(\"My Example Test\") { testKit =\u003e\n    ???\n  }\n\n  //Create multiple test kits in one fixture, and filter out the ones you need\n  allPersistenceTestKits(MyBehavior(\"test-id\")).test(\"My Persistence Test\") { \n    case (actorTestKit, eventSourcedTestKit, persistenceTestKit, snapshotTestKit) =\u003e\n      ???\n  }\n\n  //Alternatively, just get a single additional test kit you need per-test\n  snapshotTestKit.test(\"My Snapshot Test\") { case (actorTestKit, snapshotTestKit) =\u003e\n    ???  \n  }\n}\n```\n\nFixtures for all possible combinations of test kits are not available, but you can easily make per-test instances of the Persistence and Snapshot testkits by looking at the [existing Akka Persistence Typed testing documentation](https://doc.akka.io/docs/akka/current/typed/persistence-testing.html).\n\n## What about suite-wide fixtures?\nI do not recommend this style of testing, the kind that often makes use of functions called `beforeAndAfterAll` and similar.\nThis style of testing creates a linear dependency of all tests in the current suite so that their resulting states must be known for each test.\nThis increases necessary cognitive load, as well as making it difficult to add new tests or change existing ones without cascading effects or unexpected test bugs.\nInstead, I would recommend that you use the included per-test fixtures and simply extract any shared stateful initiation between tests to a function of your own.\nAlternatively, you can create your own per-test fixtures by studying how these fixtures are implemented and expanding them to fit your use-case.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F47degrees%2Fmunit-akka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F47degrees%2Fmunit-akka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F47degrees%2Fmunit-akka/lists"}