{"id":16318538,"url":"https://github.com/vic/test_async","last_synced_at":"2025-10-25T18:30:23.915Z","repository":{"id":62430407,"uuid":"76520100","full_name":"vic/test_async","owner":"vic","description":"Make tests inside your ExUnit case to run async.","archived":false,"fork":false,"pushed_at":"2016-12-19T08:15:15.000Z","size":24,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-13T13:53:03.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/vic.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":"2016-12-15T03:22:59.000Z","updated_at":"2022-07-28T21:41:41.000Z","dependencies_parsed_at":"2022-11-01T20:19:50.703Z","dependency_job_id":null,"html_url":"https://github.com/vic/test_async","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Ftest_async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Ftest_async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Ftest_async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Ftest_async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vic","download_url":"https://codeload.github.com/vic/test_async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865200,"owners_count":16555929,"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-10-10T22:23:51.117Z","updated_at":"2025-10-25T18:30:23.591Z","avatar_url":"https://github.com/vic.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TestAsync\n\u003ca href=\"https://travis-ci.org/vic/test_async\"\u003e\u003cimg src=\"https://travis-ci.org/vic/test_async.svg\"\u003e\u003c/a\u003e\n\nMake tests inside your ExUnit case to run async.\n\n## Installation\n\n[Available in Hex](https://hex.pm/packages/test_async), the package can be installed\nby adding `test_async` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:test_async, \"~\u003e 0.1\", only: :test, runtime: false}]\nend\n```\n\n## Intro\n\nAs you might already know, ExUnit lets you define async test cases by\nproviding an `async: true` option, like this:\n\n```elixir\ndefmodule App.FineTest do\n  use ExUnit.Case, async: true\n\n  test \"one\" do\n    IO.inspect :one\n  end\n\n  test \"two\" do\n    IO.inspect :two\n  end\nend\n\ndefmodule App.OtherTest do\n  use ExUnit.Case, async: true\n\n  test \"three\" do\n    IO.inspect :three\n  end\nend\n```\n\nAs described by the [ExUnit documentation](https://hexdocs.pm/ex_unit/ExUnit.html) \n\n\n\u003e `async: true`, runs the test case concurrently with other test cases. \n\u003e The individual tests within each test case are still run serially\n\nThat means, `one` and `two` will still be run one after the other.\n\nIf you'd want those two to be run concurrently, you'd have to create\na new test case module for each.\n\nThis is exactly what `TestAsync` does, by providing a tiny macro `test`\nmacro that will turn your ExUnit case tests into async cases.\n\n## Usage\n\nJust `use TestAsync` !\n\n```elixir\ndefmodule App.FineTest do\n  use ExUnit.Case\n  use TestAsync\n\n  test \"one\" do\n    IO.inspect :one\n  end\n\n  test \"two\" do\n    IO.inspect :two\n  end\nend\n```\n\n[More examples as tests](https://github.com/vic/test_async/blob/master/test/)\n\n## Gotchas\n\n#### Current module\n\nIf you use `__MODULE__` on a test body, it will be the name of the\ngenerated case module and not the one of the parent module.\n\n```elixir\ndefmodule App.NamedTest do\n  use ExUnit.Case\n\n  test \"one\" do\n    assert __MODULE__ == App.NamedTest.OneTest\n  end\nend\n```\n\n#### Setup functions\n\n`setup` and `setup_all` are supported.\nNote that now `setup_all` is run for every test \nbecause it will be live on its own test case.\n\n#### Private functions \n\nPrivate functions defined on the parent module cannot be seen inside\nthe generated async modules.\n\n```elixir\ndefmodule App.SomeTest do\n  use ExUnit.Case\n  use TestAsync\n\n  defp hidden, do: :ninja\n\n  test \"cant be seen\" do\n    assert hidden() # compile error\n  end\nend\n```\n\n#### Shared case template\n\nHowever you can give `use TestAsync` a `do` block, which will be\nturned into a shared `ExUnit.CaseTemplate`.\nWhen using your own templates, do so on the do block.\n\n```elixir\ndefmodule App.NinjaTest do\n  use ExUnit.Case\n\n  use TestAsync do\n    defp hidden, do: :ninja\n    use App.MyTestTemplate\n  end\n\n  test \"can be seen\" do\n    assert hidden()\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvic%2Ftest_async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvic%2Ftest_async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvic%2Ftest_async/lists"}