{"id":15698953,"url":"https://github.com/ignacio-chiazzo/ruby-minitest-analyzer","last_synced_at":"2025-08-05T08:14:21.783Z","repository":{"id":43179481,"uuid":"427527104","full_name":"ignacio-chiazzo/ruby-minitest-analyzer","owner":"ignacio-chiazzo","description":"Don't run duplicated test in Minitest! Analyzes Ruby Minitest repeated tests health.","archived":false,"fork":false,"pushed_at":"2022-07-20T21:36:41.000Z","size":74,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-28T14:17:19.772Z","etag":null,"topics":["hackoctoberfest","hackoctoberfest-accepted","minitest","rails","ruby","testing"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ignacio-chiazzo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-12T23:58:17.000Z","updated_at":"2023-06-13T03:06:07.000Z","dependencies_parsed_at":"2022-08-26T14:31:10.975Z","dependency_job_id":null,"html_url":"https://github.com/ignacio-chiazzo/ruby-minitest-analyzer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ignacio-chiazzo/ruby-minitest-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignacio-chiazzo%2Fruby-minitest-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignacio-chiazzo%2Fruby-minitest-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignacio-chiazzo%2Fruby-minitest-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignacio-chiazzo%2Fruby-minitest-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ignacio-chiazzo","download_url":"https://codeload.github.com/ignacio-chiazzo/ruby-minitest-analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignacio-chiazzo%2Fruby-minitest-analyzer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268859123,"owners_count":24318874,"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","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"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":["hackoctoberfest","hackoctoberfest-accepted","minitest","rails","ruby","testing"],"created_at":"2024-10-03T19:36:35.300Z","updated_at":"2025-08-05T08:14:21.726Z","avatar_url":"https://github.com/ignacio-chiazzo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby Minitest Analyzer\n\nMinitest uses Ruby classes, **if a Minitest class inherits from another class, it will also inherit its methods causing Minitest to run the parent's tests twice.**\nIn some cases, we want them to run them twice, but most of the time, we don't.  \n\nRuby Minitest Analyzer will analyze your Minitest classes and detect any duplicate test run.\n\n![Untitled-2022-03-13-1106](https://user-images.githubusercontent.com/11672878/158284753-08ea962f-9ac6-46a6-acec-e2464a258a41.png)\n\n**This Library is explained in detail in [this Post](https://ignaciochiazzo.medium.com/dont-run-your-ruby-minitest-classes-twice-988645662cdb)**\n\n### Example\nSee the following case. \n\n```ruby\nrequire \"minitest\"\nrequire \"minitest/autorun\"\n\nclass ProductParentTest \u003c Minitest::Test\n  def test_parent\n    puts __method__\n  end\nend\n\nclass ProductTest \u003c ProductParentTest\n  def test_1\n    puts __method__\n  end\n\n  def test_2\n    puts __method__\n  end\nend\n```\nHow many tests will we run if we run the `ProductTest` tests? 4! (yes, four). Try it!\n\n```console\n# Running:\n\ntest_2\ntest_parent\ntest_1\ntest_parent\n\nFinished in 0.001218s, 3284.0724 runs/s, 0.0000 assertions/s.\n4 runs, 0 assertions, 0 failures, 0 errors, 0 skips\n```\n\nThe reason is that `ProductTest` is a subclass of `ProductParentTest`.\n\nNote: I added a [new cop to Rubocop](https://github.com/rubocop/rubocop-minitest/pull/164) that checks for duplicated run tests. The cop has some limitations that this library solves. For example, in the cop, the classes should be in the same file. \n\n**More details in [this Post](https://ignaciochiazzo.medium.com/dont-run-your-ruby-minitest-classes-twice-988645662cdb)**\n\nOther scenarios were it doesn't create duplicated tests:\n\n\u003cdetails\u003e\u003csummary\u003eWhen the class is under a parent Minitest class but it doesn't inherit from it.\u003c/summary\u003e\n\n```ruby\nclass A \u003c Minitest\n  test xyz do \n  end\n\n  class B \u003c Minitest\n    test bar do \n    end\n  end\n\n  class C \u003c Minitest\n    test foo do \n    end\n  end\nend\n```\n\n\u003c/details\u003e\n\n## Installation\n\nAdd this line to your Application's Gemfile:\n\n```ruby\ngem 'ruby_minitest_analyzer'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ruby_minitest_analyzer\n\n### How can I run the analyzer on my Application?\n\n1) Create a new test `minitest_analyzer.rb` file.\n2) Create a method `require_all_test_files` requiring all the tests files, including\nthe files needed to run the tests e.g. `test_helper.rb`. See the example below.\n3) Call `::RubyMinitestAnalyzer.run!(nil)`.\n4) Run the file.\n\n\u003cdetails\u003e\n\u003csummary\u003e minitest_analyzer.rb example:\u003c/summary\u003e\n  \n```ruby\n# I placed this file within /test\n  \nrequire_relative 'test_helper.rb'\nrequire 'ruby_minitest_analyzer' \n\ndef require_all_files\n  # require test_helpers\n  require_relative(\"test_helper\")\n\n  # require tests classes\n  Dir[File.expand_path('**/*.rb', __dir__)].each do |f|\n    require_relative(f)\n  end\nend\n\nrequire_all_files\n::RubyMinitestAnalyzer.run!(nil)\n```\n\u003c/details\u003e\n\nRunning the file example:\n\n```console\n➜  rails-minitest-analyzer git:(main) ✗ ruby minitest.rb \n---------------Setting up---------------\nRequiring files...\nTotal of 6 test classes to analyze. \n---------------Setup finished! Ready to analyze the tests---------------\nAnalyzing!\n\nAnalyzed a total of 6 classes.\n      \n* Total duplicated tests that can be removed: 12\n* Total classes with duplicated tests: 3 \n      \nClasses that run the tests multiple times: \n\nCLASS NAME      | CLASS_TEST_METHODS_COUNT | CLASS_DESCENDANT_COUNT | EXTRA_TESTS_EXECUTIONS_COUNT \n----------------|--------------------------|------------------------|------------------------------\nGrandParentTest | 1                        | 5                      | 5                            \nParent1Test     | 2                        | 2                      | 4                            \nParent2Test     | 3                        | 1                      | 3                            \n\nFinished!  \n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby_minitest_analyzer.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignacio-chiazzo%2Fruby-minitest-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fignacio-chiazzo%2Fruby-minitest-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignacio-chiazzo%2Fruby-minitest-analyzer/lists"}