{"id":20237731,"url":"https://github.com/ragmaanir/microtest","last_synced_at":"2025-04-10T19:12:10.810Z","repository":{"id":136218079,"uuid":"59341769","full_name":"Ragmaanir/microtest","owner":"Ragmaanir","description":"Small test framework, because it has power asserts as the only assertion.","archived":false,"fork":false,"pushed_at":"2025-03-24T02:19:19.000Z","size":2645,"stargazers_count":30,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T03:24:09.563Z","etag":null,"topics":["crystal","microtest","power-assert","test-framework","testing"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/Ragmaanir.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-05-21T04:30:52.000Z","updated_at":"2025-03-24T02:19:22.000Z","dependencies_parsed_at":"2024-01-30T16:04:56.001Z","dependency_job_id":"55950ce4-e354-42cf-a4e5-5f1a1f185bc0","html_url":"https://github.com/Ragmaanir/microtest","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fmicrotest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fmicrotest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fmicrotest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fmicrotest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ragmaanir","download_url":"https://codeload.github.com/Ragmaanir/microtest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248279825,"owners_count":21077408,"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":["crystal","microtest","power-assert","test-framework","testing"],"created_at":"2024-11-14T08:28:38.399Z","updated_at":"2025-04-10T19:12:10.789Z","avatar_url":"https://github.com/Ragmaanir.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔬 microtest [![Crystal CI](https://github.com/Ragmaanir/microtest/actions/workflows/crystal.yml/badge.svg)](https://github.com/Ragmaanir/microtest/actions/workflows/crystal.yml)\n\n### Version 1.2.7\n\nA small testing framework inspired by minitest/minitest.cr.\n\n## Features\n\n- This framework is opinionated\n- It uses power asserts by default. There are no `assert_equals`, `assert_xyz`, just power asserts (except for `assert_raises`)\n- It uses the spec syntax for test case structure (`describe`, `test`, `before`, `after`). Reasons: No test-case name-clashes when using describe. Not forgetting to call super in setup/teardown methods.\n- No nesting of describe blocks. IMO nesting of those blocks is an anti-pattern.\n- No let-definitions. Only before / after hooks. Use local variables mostly.\n- Tests have to be started explicitly by `Microtest.run!`, no at-exit hook.\n- Colorized and abbreviated exception stacktraces\n- Randomized test order (SEED can be specified as environment variable)\n- Focus individual tests (`test! \"my test\" do ...`)\n- Different reportes (progress, descriptions, slow tests)\n\n## Installation\n\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndevelopment_dependencies:\n  microtest:\n    github: ragmaanir/microtest\n    version: ~\u003e 1.2.7\n```\n\nAnd add this to your `spec_helper.rb`:\n\n```crystal\nrequire \"microtest\"\n\ninclude Microtest::DSL\n\nMicrotest.run!\n```\n\n\n## Usage\n\n```crystal\nclass WaterPump\n  getter name : String\n  getter speed : Int32\n  getter? enabled : Bool = false\n\n  def initialize(@name, @speed = 10)\n  end\n\n  def enable\n    @enabled = true\n  end\nend\n\ndescribe WaterPump do\n  test \"enabling\" do\n    p = WaterPump.new(\"main\")\n    p.enable\n\n    assert(p.enabled?)\n  end\n\n  test \"pump speed\" do\n    p = WaterPump.new(\"main\", speed: 100)\n\n    assert(p.speed \u003e 50)\n  end\n\n  test \"this one is pending since it got no body\"\n\n  pending \"this one is pending even though it has a body\" do\n    raise \"should not raise\"\n  end\nend\n\n```\n\nRun the test with:\n\n`crystal spec`\n\nYou can provide the seed to run the tests in the same order:\n\n`SEED=123 crystal spec`\n\n## Power Assert Output\n\n```crystal\ndescribe AssertionFailure do\n  test \"assertion failure\" do\n    a = 5\n    b = \"aaaaaa\"\n    assert \"a\" * a == b\n  end\nend\n\n```\n\nGenerates:\n\n![missing](assets/assertion_failure.jpg?raw=true)\n\n### Microtest Test Output (microtest tests using progress reporter)\n\n![missing](assets/spec.jpg?raw=true)\n\n## Reporters\n\nUse common reporter combinations:\n\n```crystal\n# both versions include error-list-, slow-tests- and summary-reporters:\nMicrotest.run!(:progress)\nMicrotest.run!(:descriptions)\n```\n\nOr select the used reporters explicitly:\n\n```crystal\nMicrotest.run!([\n  Microtest::DescriptionReporter.new,\n  Microtest::ErrorListReporter.new,\n  Microtest::SlowTestsReporter.new,\n  Microtest::SummaryReporter.new,\n] of Microtest::Reporter)\n```\n\n```crystal\ndescribe First do\n  test \"success\" do\n  end\n\n  test \"skip this\"\nend\n\ndescribe Second do\n  def raise_an_error\n    raise \"Oh, this is wrong\"\n  end\n\n  test \"first failure\" do\n    a = 5\n    b = 7\n    assert a == b * 2\n  end\n\n  test \"error\" do\n    raise_an_error\n  end\nend\n\n```\n\n### Progress Reporter\n![missing](assets/progress_reporter.jpg?raw=true)\n\n### Description Reporter\n![missing](assets/description_reporter.jpg?raw=true)\n\n### When focus active\n\n```crystal\ndescribe Focus do\n  test \"not focused\" do\n  end\n\n  test! \"focused\" do\n  end\n\n  test \"focused too\", :focus do\n  end\nend\n\n```\n\n![missing](assets/focus.jpg?raw=true)\n\n## Development\n\nRun `./cli readme` to run tests and generate `README.md` from `README.md.ecr` and generate the images of the test outputs (using an alpine docker image).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragmaanir%2Fmicrotest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fragmaanir%2Fmicrotest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragmaanir%2Fmicrotest/lists"}