{"id":22769818,"url":"https://github.com/bfontaine/crtest","last_synced_at":"2025-03-30T11:29:50.085Z","repository":{"id":20493517,"uuid":"23771802","full_name":"bfontaine/crtest","owner":"bfontaine","description":"Tests module for Crystal","archived":false,"fork":false,"pushed_at":"2014-09-07T21:49:49.000Z","size":116,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T23:43:39.956Z","etag":null,"topics":["crystal","library","unittest"],"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/bfontaine.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":"2014-09-07T21:43:35.000Z","updated_at":"2017-06-30T15:40:59.000Z","dependencies_parsed_at":"2022-08-21T18:20:56.417Z","dependency_job_id":null,"html_url":"https://github.com/bfontaine/crtest","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/bfontaine%2Fcrtest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fcrtest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fcrtest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bfontaine%2Fcrtest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bfontaine","download_url":"https://codeload.github.com/bfontaine/crtest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246313203,"owners_count":20757446,"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","library","unittest"],"created_at":"2024-12-11T15:15:57.638Z","updated_at":"2025-03-30T11:29:50.052Z","avatar_url":"https://github.com/bfontaine.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crtest\n\n`crtest` is a simple tests module for [Crystal][].\n\n[Crystal]: http://crystal-lang.org/\n\nNote: This was written with/for Crystal 0.4.3. The language API is not stable\nright now, this library might not work with future versions.\n\n## Usage\n\nWrite your code as usual, using the `$TESTS` global variable to check if you’re\nin a test environment.\n\nFor example:\n\n```crystal\n# hello.cr\n\ndef hello(name)\n  puts \"hello #{name}\"\nend\n\nhello(\"world\") unless $TEST\n```\n\nWrite your tests in another file, and require `crtest` at its top:\n\n```crystal\n# hello_tests.cr\n\nrequire \"crtest\"\nrequire \"./hello\"\n```\n\nTests must be enclosed in a test suit:\n\n```crystal\n# declare a tests suit, with an optional name\nts = TestsSuite.new \"MyTestSuite\"\n\nts.run do |tr|\n  # all your tests\nend\n```\n\nEach test is another block:\n\n```crystal\n  tr.test(\"an awesome feature\") do |t|\n    # ...\n  end\n```\n\n`t` is a test runner. It has the following test methods:\n\n* `assert_equal(ref, value)`: pass only if both values are equal (`==`)\n* `assert_true(value)`: pass only if `value` is truthy\n* `assert_false(value)`: pass only if `value` is falsy\n* `assert_nil(value)`: pass only if `value` is `nil`\n\nYou can also use the lower-level method `assert`:\n\n```crystal\nt.assert(\"didn't work as expected\") do\n  # ...\nend\n```\n\nIt takes a text to print if the test fails, and a block. The block must return\na `truthy` value (i.e. not `false` or `nil`) to be considered as a success.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfontaine%2Fcrtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbfontaine%2Fcrtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbfontaine%2Fcrtest/lists"}