{"id":13801485,"url":"https://github.com/disneystreaming/weaver-test","last_synced_at":"2025-05-16T01:06:14.295Z","repository":{"id":38996768,"uuid":"258577103","full_name":"disneystreaming/weaver-test","owner":"disneystreaming","description":"A test framework that runs everything in parallel. ","archived":false,"fork":false,"pushed_at":"2024-09-03T21:04:46.000Z","size":3568,"stargazers_count":445,"open_issues_count":50,"forks_count":49,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-08T11:15:00.037Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://disneystreaming.github.io/weaver-test/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/disneystreaming.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-24T17:21:55.000Z","updated_at":"2025-02-28T12:54:00.000Z","dependencies_parsed_at":"2024-03-26T15:32:19.987Z","dependency_job_id":"1dfac172-6342-4906-97cf-2926083bceda","html_url":"https://github.com/disneystreaming/weaver-test","commit_stats":null,"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disneystreaming%2Fweaver-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disneystreaming%2Fweaver-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disneystreaming%2Fweaver-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disneystreaming%2Fweaver-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/disneystreaming","download_url":"https://codeload.github.com/disneystreaming/weaver-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"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":[],"created_at":"2024-08-04T00:01:23.332Z","updated_at":"2025-05-16T01:06:09.287Z","avatar_url":"https://github.com/disneystreaming.png","language":"Scala","readme":"\u003cimg src=\"https://github.com/disneystreaming/weaver-test/raw/main/website/static/img/logo.png\" width=\"200px\" height=\"231px\" align=\"right\"\u003e\n\n[![CI](https://github.com/disneystreaming/weaver-test/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/disneystreaming/weaver-test/actions/workflows/ci.yml)\n[![Latest version](https://index.scala-lang.org/disneystreaming/weaver-test/weaver-core/latest.svg?color=orange)](https://index.scala-lang.org/disneystreaming/weaver-test/weaver-core)\n[![Gitter](https://img.shields.io/gitter/room/disneystreaming/weaver-test.svg)](https://gitter.im/disneystreaming/weaver-test)\n[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)\n[![CLA assistant](https://cla-assistant.io/readme/badge/disneystreaming/weaver-test)](https://cla-assistant.io/disneystreaming/weaver-test)\n\n# PLEASE READ THIS : \n\nThe stewardship of Weaver is being moved to Typelevel. This repository will no longer receive any development, and will be archived after the first release by the Typelevel version. You can follow the progress here : https://github.com/typelevel/weaver-test/issues/1\n\n# Weaver-test\n\nA test-framework built on [cats-effect](https://github.com/typelevel/cats-effect) and\n[fs2](https://github.com/functional-streams-for-scala/fs2)\n\n## Installation\n\nWeaver-test is currently published for **Scala 2.12, 2.13, and 3.0**\n\n### SBT\n\nRefer yourself to the [releases](https://github.com/disneystreaming/weaver-test/releases) page to know the latest released version, and add the following (or scoped equivalent) to your `build.sbt` file.\n\n```scala\nlibraryDependencies += \"com.disneystreaming\" %% \"weaver-cats\" % \"x.y.z\" % Test\ntestFrameworks += new TestFramework(\"weaver.framework.CatsEffect\")\n\n// optionally (for Scalacheck usage)\nlibraryDependencies +=  \"com.disneystreaming\" %% \"weaver-scalacheck\" % \"x.y.z\" % Test\n```\n\n## Motivation\n\n![time](docs/assets/time.png)\n\nWeaver aims at providing a nice experience when writing and running tests :\n\n- tests within a suite are run in parallel by default for quickest results possible\n- expectations (ie assertions) are composable values. This forces\n  developers to separate the scenario of the test from the checks they perform,\n  which generally keeps tests cleaner / clearer.\n- failures are aggregated and reported at the end of the run. This prevents the developer from having to \"scroll up\" forever when trying to understand what failed.\n- a lazy logger is provided for each test, and log statements are only displayed in case of a test failure. This lets the developer enrich their tests with clues and works perfectly well with parallel runs\n\n## API\n\n### Example suites (cats-effect)\n\n#### SimpleIOSuite\n\nThe suite that is most familiar to developers :\n\n```scala mdoc\nimport weaver.SimpleIOSuite\nimport cats.effect._\n\n// Suites must be \"objects\" for them to be picked by the framework\nobject MySuite extends SimpleIOSuite {\n\n  pureTest(\"non-effectful (pure) test\"){\n    expect(\"hello\".size == 6)\n  }\n\n  private val random = IO(java.util.UUID.randomUUID())\n\n  test(\"test with side-effects\") {\n    for {\n      x \u003c- random\n      y \u003c- random\n    } yield expect(x != y)\n  }\n\n  loggedTest(\"test with side-effects and a logger\"){ log =\u003e\n    for {\n      x \u003c- random\n      _ \u003c- log.info(s\"x : $x\")\n      y \u003c- random\n      _ \u003c- log.info(s\"y : $y\")\n    } yield expect(x != y)\n  }\n}\n```\n\n#### IOSuite\n\nThe `IOSuite` constructs the given resource once for all tests in the suite.\n\n```scala mdoc:reset\nimport weaver.IOSuite\nimport cats.effect._\n\nobject MySuite extends IOSuite {\n\n  type Res = Int\n\n  def sharedResource : Resource[IO, Int] = Resource\n    .make(\n      IO(println(\"Making resource\"))\n        .as(123)\n    )(n =\u003e IO(println(s\"Closing resource $n\")))\n\n  test(\"test, but resource not visible\"){\n    IO(expect(123 == 123))\n  }\n\n  test(\"test with resource\"){ n =\u003e\n    IO(expect(n == 123))\n  }\n\n  test(\"test with resource and a logger\"){ (n, log) =\u003e\n    log.info(\"log was available\") *\u003e\n    IO(expect(n == 123))\n  }\n}\n```\n\n#### Other suites\n\nWeaver also includes support for\n\n\n| Alias             | Suite name               | Provided by        | Use case                                      |\n| ----------------- | ------------------------ | ------------------ | --------------------------------------------- |\n| `SimpleIOSuite`   | `SimpleMutableIOSuite`   | `weaver-cats`      | Each test is a standalone `IO` action         |\n| `IOSuite`         | `MutableIOSuite`         | `weaver-cats`      | Each test needs access to a shared `Resource` |\n\n### Expectations (assertions)\n\n#### Building expectations\n\nThe various `test` functions have in common that they expect the developer to return a value of type `Expectations`, which is just a basic case class wrapping a `cats.data.Validated` value.\n\nThe most convenient way to build `Expectations` is to use the `expect` function. Based on [Eugene Yokota's](http://eed3si9n.com/about) excellent [expecty](https://github.com/eed3si9n/expecty), it captures the boolean expression at compile time and provides useful feedback on what goes wrong when it does :\n\n![Oops](docs/assets/oops.png)\n\nNothing prevents the user from building their own expectations functions to resemble what they're used to.\n\n#### Composing expectations\n\nSomething worth noting is that expectations are not throwing, and that if the user wants to perform several checks in the same test, he needs to compose the expectations via the `and` or the `or` methods they carry.\n\n### Filtering tests\n\nWhen using the IOSuite variants, the user can call `sbt`'s test command as such:\n\n``` \n\u003e testOnly -- -o *foo*\n```\n\nThis filter will prevent the execution of any test that doesn't contain the string \"foo\" in is qualified name. For a test labeled \"foo\" in a \"FooSuite\" object, in the package \"fooPackage\", the qualified name of a test is:\n\n```\nfooPackage.FooSuite.foo\n```\n\n### Running suites in standalone\n\nIt is possible to run suites outside of your build tool, via a good old `main` function. To do so, you can instantiate the `weaver.Runner`, create a `fs2.Stream` of the suites you want to run, and call `runner.run(stream)`.\n\nThis is useful when you consider your tests (typically `end-to-end` ones) as a program of its own and want to avoid paying the cost of compiling them every time you run them.\n\n### Scalacheck (property-based testing)\n\nWeaver comes with basic scalacheck integration.\n\n```scala mdoc\nimport weaver._\nimport weaver.scalacheck._\nimport org.scalacheck.Gen\n\n// Notice the Checkers mix-in\nobject ForallExamples extends SimpleIOSuite with Checkers {\n\n  // CheckConfig can be overridden at the test suite level\n  override def checkConfig: CheckConfig =\n    super.checkConfig.copy(perPropertyParallelism = 100)\n\n  test(\"Gen form\") {\n    // Takes an explicit \"Gen\" instance. There is only a single\n    // version of this overload. If you want to pass several Gen instances\n    // at once, just compose them monadically.\n    forall(Gen.posNum[Int]) { a =\u003e\n      expect(a \u003e 0)\n    }\n  }\n\n  test(\"Arbitrary form\") {\n    // Takes a number of implicit \"Arbitrary\" instances. There are 6 overloads\n    // to pass 1 to 6 parameters.\n    forall { (a1: Int, a2: Int, a3: Int) =\u003e\n      expect(a1 * a2 * a3 == a3 * a2 * a1)\n    }\n  }\n\n  test(\"foobar\") {\n    // CheckConfig can be overridden locally\n    forall.withConfig(super.checkConfig.copy(perPropertyParallelism = 1,\n                                             initialSeed = Some(7L))) {\n      (x: Int) =\u003e\n        expect(x \u003e 0)\n    }\n  }\n\n}\n```\n\n## Contributing\n\nContributions are most welcome !\n\n### Development requirements\n\n:warning: This repository uses [Git LFS](https://git-lfs.github.com/). Having it installed is required for\n`git checkout` to work properly.\n\nTo install for Mac using `brew`:\n\n```bash\nbrew install git-lfs\ngit lfs install\n```\n\nIf you want to build and run the website then you will need yarn installed:\n\n```bash\nbrew install yarn\n```\n\n### Building the website\n\nIf you're changing documentation, here's how you can check your changes locally:\n\n```bash\nsbt docs/docusaurusCreateSite\ncd website\nyarn start\n```\n\nIf you're only changing `.md` files, you can run `sbt '~docs/mdoc'`.\n\nNote that the site will look a tiny bit different because to build a versioned website we have some machinery in the script running on CI - but you don't have to worry about that.\n\n### IntelliJ plugin\n\nThe code of the IntelliJ plugin lives [there](https://github.com/disneystreaming/weaver-intellij)\n\n### PR Guidelines\n\nPlease:\n\n- Sign the CLA\n- Write positive and negative tests\n- Include documentation\n\n## Inspiration\n\nA **HUGE** thank you to Alexandru Nedelcu, author of [Monix](https://github.com/monix/monix) and contributor to\ncats-effect, as he wrote the [minitest](https://github.com/monix/minitest)\nframework which got this framework started.\n","funding_links":[],"categories":["Table of Contents"],"sub_categories":["Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisneystreaming%2Fweaver-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdisneystreaming%2Fweaver-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisneystreaming%2Fweaver-test/lists"}