{"id":15684627,"url":"https://github.com/byroot/megatest","last_synced_at":"2026-03-16T16:36:17.284Z","repository":{"id":253979595,"uuid":"820255181","full_name":"byroot/megatest","owner":"byroot","description":"WIP","archived":false,"fork":false,"pushed_at":"2025-02-22T09:17:31.000Z","size":277,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-30T22:15:44.706Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/byroot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2024-06-26T05:43:47.000Z","updated_at":"2025-02-22T09:17:35.000Z","dependencies_parsed_at":"2024-10-23T18:09:25.659Z","dependency_job_id":"d81c594f-fc84-416d-a795-524cf848fb76","html_url":"https://github.com/byroot/megatest","commit_stats":null,"previous_names":["byroot/megatest"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmegatest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmegatest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmegatest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byroot%2Fmegatest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byroot","download_url":"https://codeload.github.com/byroot/megatest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789627,"owners_count":21644087,"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-03T17:20:14.785Z","updated_at":"2026-03-16T16:36:17.277Z","avatar_url":"https://github.com/byroot.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Megatest\n\nMegatest is a test-unit like framework with a focus on usability, and designed with continuous integration in mind.\n\n## Installation\n\nInstall the gem and add it to the application's Gemfile by executing:\n\n    $ bundle add megatest\n\n## Usage\n\n### Special Files And Directories\n\nBy default, tests are assumed to live in the `test` directory. If present, the\noptional files `test/test_config.rb` and `test/test_helper.rb` are loaded\nautomatically, and in that order.\n\n#### test/test_config.rb\n\nThe `megatest` CLI offers options to override default settings, but if you'd\nlike to have some always set, please do so in the optional\n`test/test_config.rb`:\n\n```ruby\n# test/test_config.rb\n\nMegatest.config do |config|\n  # See Megatest::Config.\nend\n```\n\n#### test/test_helper.rb\n\nThe optional file `test/test_helper.rb` is meant to centralize dependencies and\ndefine test helpers:\n\n```ruby\n# test/test_helper.rb\n\nrequire \"some_dependency\"\n\nmodule MyApp\n  class Test \u003c Megatest::Test\n    def some_helper(arg)\n    end\n  end\nend\n```\n\n### Writing Tests\n\nTest suites are Ruby classes that inherit from `Megatest::Test`.\n\nTest cases are defined with the `test` macro, or for compatibility with existing test suites,\nby defining a method starting with `test_`.\n\nAll the classic `test-unit` and `minitest` assertion methods are available:\n\n```ruby\n# test/some_test.rb\n\nclass SomeTest \u003c MyApp::Test\n  setup do\n    @user = User.new(\"George\")\n  end\n\n  test \"the truth\" do\n    assert_equal true, Some.truth\n  end\n\n  def test_it_works\n    assert_predicate 2, :even?\n  end\nend\n```\n\nMegatest also allows to define tests inside `context` blocks, to make it easier to group\nrelated tests together and have them share a common name prefix.\n\n```ruby\nclass SomeTest \u003c MyApp::Test\n  context \"when on earth\" do\n    test \"1 is odd\" do\n      App.location = \"earth\"\n      assert_predicate 1, :odd?\n    end\n\n    test \"2 is even\" do\n      App.location = \"earth\"\n      assert_predicate 2, :even?\n    end\n  end\nend\n```\n\nNote however that context blocks aren't test suites, they don't have their own setup or teardown\nblocks, nor their own namespaces.\n\n### Command Line\n\nContrary to many alternatives, `megatest` provides a convenient CLI interface to easily run specific tests.\n\nRun all tests in a directory:\n\n```bash\n$ megatest # Run all tests in `test/`\n$ megatest test/integration\n```\n\nRuns tests using 8 processes:\n\n```bash\n$ megatest -j 8\n```\n\nRun a test at the specific line:\n\n```bash\n$ megatest test/some_test.rb:42 test/other_test.rb:24\n```\n\nRun all tests matching a pattern:\n\n```bash\n$ megatest test/some_test.rb:/matching\n```\n\nFor more detailed usage, run `megatest --help`.\n\n### CI Parallelization\n\nMegatest offers multiple features to allow running test suites in parallel across\nmany CI jobs.\n\n#### Sharding\n\nThe simplest way is sharding. Each worker will run its share of the test cases.\n\nMany CI systems provide a way to run the same command on multiple nodes,\nand will generally expose environment variables to help split the workload.\n\n```yaml\n- label: \"Run Unit Tests\"\n  run: megatest --workers-count $CI_NODE_TOTAL --worker-id $CI_NODE_INDEX\n  parallel: 8\n```\n\nNote that Megatest makes no effort at balancing the shards as it has no\ninformation about how long each individual test case is expected to take.\nHowever it does shard test cases individually, so it avoids the most common issue which is\nvery large test suites containing lots of slow test cases being sharded as one unit.\n\nIf you are using CircleCI, Buildkite or HerokuCI, the workers count and worker id\nwill be automatically inferred from the environment.\n\n#### Redis Distribution\n\nA more efficient way to parallelize tests on CI is to use a Redis server to act as a queue.\n\nThis allows to efficiently and dynamically ensure a near perfect test case balance across all\nthe workers. And if for some reason one of the workers is lost or crashes, no test is lost,\nwhich for builds with hundreds of parallel jobs, is essential for stability.\n\n```yaml\n- label: \"Run Unit Tests\"\n  run: megatest --queue redis://redis-ci.example.com --build-id $CI_BUILD_ID --worker-id $CI_JOB_ID\n  parallel: 128\n  soft_fail: true # Doesn't matter if they fail or crash, only the \"Results\" job status matters\n\n- label: \"Unit Test Results\"\n  run: megatest report --queue redis://redis-ci.example.com --build-id $CI_BUILD_ID\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/byroot/megatest.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyroot%2Fmegatest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyroot%2Fmegatest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyroot%2Fmegatest/lists"}