{"id":13683411,"url":"https://github.com/petitest/petitest","last_synced_at":"2025-03-16T19:22:05.138Z","repository":{"id":56887886,"uuid":"85612135","full_name":"petitest/petitest","owner":"petitest","description":"A minimal solid testing framework for Ruby.","archived":false,"fork":false,"pushed_at":"2017-03-26T06:22:51.000Z","size":240,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T23:19:57.688Z","etag":null,"topics":["petitest","ruby","test-framework"],"latest_commit_sha":null,"homepage":null,"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/petitest.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":"2017-03-20T18:30:28.000Z","updated_at":"2018-10-26T19:09:42.000Z","dependencies_parsed_at":"2022-08-21T00:50:45.822Z","dependency_job_id":null,"html_url":"https://github.com/petitest/petitest","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petitest%2Fpetitest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petitest%2Fpetitest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petitest%2Fpetitest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petitest%2Fpetitest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petitest","download_url":"https://codeload.github.com/petitest/petitest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243776840,"owners_count":20346357,"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":["petitest","ruby","test-framework"],"created_at":"2024-08-02T13:02:10.337Z","updated_at":"2025-03-16T19:22:05.118Z","avatar_url":"https://github.com/petitest.png","language":"Ruby","readme":"# Petitest\n\n[![Gem Version](https://badge.fury.io/rb/petitest.svg)](https://rubygems.org/gems/petitest)\n[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/github/petitest/petitest)\n\nA minimal solid testing framework for Ruby.\n\n![demo](/images/demo.png)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"petitest\"\n```\n\nAnd then execute:\n\n```bash\nbundle\n```\n\nOr install it yourself as:\n\n```bash\ngem install petitest\n```\n\n## Usage\n\n### Create your test file\n\nDefine a child class of `Petitest::Test` with `#test_xxx` methods.\n\n```ruby\nrequire \"petitest/autorun\"\n\nclass ExampleTest \u003c Petitest::Test\n  def test_addition\n    assert { 1 + 1 == 100 }\n  end\nend\n```\n\n### Run it as a Ruby script\n\nRun your test file as a Ruby script:\n\n```bash\nruby test/example_test.rb\n```\n\n```\nPetitestTest\n  #test_one_plus_one_to_be_two\n\n\nCounts:\n\n  1 tests\n  1 passes\n  0 failures\n  0 skips\n\nTimes:\n\n  Started:  2017-03-25T15:29:21.243918+09:00\n  Finished: 2017-03-25T15:29:21.244149+09:00\n  Total:    0.000231s\n```\n\nIf any test failed, exit code 1 is returned, othewise 0.\n\n```bash\necho $?\n```\n\n```\n0\n```\n\n### Run all tests\n\nRequire `\"rake/testtask\"` and initialize `Rake::TestTask` on your Rakefile like:\n\n```ruby\nrequire \"rake/testtask\"\nRake::TestTask.new\n```\n\nRun `test` rake task that you defined in the above code to run all tests:\n\n```bash\nrake test\n```\n\nNote that Rake::TestTask's default test file pattern is `test/test*.rb`.\n\n## Assertions\n\nPetitest provides only one assertion method, `#assert`.\n\n```ruby\nassert { foo }\n```\n\nIf you need more assertions, use plugins like [patitest-assertions](https://github.com/petitest/petitest-assertions).\n\n## Configuration\n\n### backtrace_filters\n\nMechanism for filter out unnecessary lines from error backtrace.\nEach element must be able to respond to `#===` method.\n\n```ruby\nPetitest.configuration.backtrace_filters = [\n  -\u003e (line) { line.start_with?(\"/path/to/petitest/lib\") },\n]\n```\n\n### color\n\nEnable colored output.\n\n```ruby\nPetitest.configuration.color = true\n```\n\n### color_scheme\n\nColor scheme for colored output.\n\n```ruby\nPetitest.configuration.color_scheme = {\n  detail: :cyan,\n  error: :red,\n  pass: :green,\n  skip: :yellow,\n}\n```\n\nThese color types are available on color scheme configuration:\n\n- `:black`\n- `:blue`\n- `:bold`\n- `:cyan`\n- `:green`\n- `:magenta`\n- `:red`\n- `:white`\n- `:yellow`\n\n### output\n\nOutput path for some subscribers.\n\n```ruby\nPetitest.configuration.output = ::STDOUT\nPetitest.configuration.output.sync = true\n```\n\n### subscribers\n\nTest event subscribers (test reporters are kind of subscribers).\n\n```ruby\nPetitest.configuration.subscribers = [\n  ::Petitest::Subscribers::DocomentReportSubscriber.new,\n]\n```\n\nThese subscribers are provided by default:\n\n- `Petitest::Subscribers::DocumentReportSubscriber` (default)\n- `Petitest::Subscribers::JsonReportSubscriber`\n- `Petitest::Subscribers::ProgressReportSubscriber`\n\n## Official Plugins\n\nHere are some official plugins for Petitest:\n\n- https://github.com/petitest/petitest-assertions\n- https://github.com/petitest/petitest-dsl\n- https://github.com/petitest/petitest-power_assert\n- https://github.com/petitest/petitest-spec\n- https://github.com/petitest/petitest-tap\n\n## For developers\n\n### Tree\n\n```\nTestPlan\n|---TestGroup 1\n|   |---Test 1-1\n|   |---Test 1-2\n|   |---Test 1-3\n|   `---TestGroup1-1\n|       |---Test 1-1-1\n|       |---Test 1-1-2\n|       `---Test 1-1-3\n|---TestGroup2\n|   |---Test 2-1\n|   |---Test 2-2\n|   `---Test 2-3\n`---TestGroup3\n    |---Test 3-1\n    |---Test 3-2\n    |---Test 3-3\n    `---TestGroup3-1\n        |---Test 3-1-1\n        |---Test 3-1-2\n        `---Test 3-1-3\n```\n\n### Order\n\n1. Test 1-1\n1. Test 1-2\n1. Test 1-3\n1. Test 1-1-1\n1. Test 1-1-2\n1. Test 1-1-3\n1. Test 2-1\n1. Test 2-2\n1. Test 2-3\n1. Test 3-1\n1. Test 3-2\n1. Test 3-3\n1. Test 3-1-1\n1. Test 3-1-2\n1. Test 3-1-3\n\n### Events\n\n- `#before_running_test_plan(test_plan)`\n- `#before_running_test_group(test_group)`\n- `#before_running_test(test)`\n- `#after_running_test(test)`\n- `#after_running_test_group(test_group)`\n- `#after_running_test_plan(test_plan)`\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetitest%2Fpetitest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetitest%2Fpetitest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetitest%2Fpetitest/lists"}