{"id":13896716,"url":"https://github.com/norman/telescope","last_synced_at":"2025-07-16T08:46:17.811Z","repository":{"id":644416,"uuid":"286495","full_name":"norman/telescope","owner":"norman","description":"A highly customizable test library for Lua that allows declarative tests with nested contexts.","archived":false,"fork":false,"pushed_at":"2017-08-05T18:32:37.000Z","size":471,"stargazers_count":162,"open_issues_count":8,"forks_count":35,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-13T21:29:03.834Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://norman.github.com/telescope/","language":"Lua","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/norman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-08-24T13:18:47.000Z","updated_at":"2025-02-16T03:53:05.000Z","dependencies_parsed_at":"2022-08-16T10:35:09.575Z","dependency_job_id":null,"html_url":"https://github.com/norman/telescope","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/norman/telescope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norman%2Ftelescope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norman%2Ftelescope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norman%2Ftelescope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norman%2Ftelescope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/norman","download_url":"https://codeload.github.com/norman/telescope/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norman%2Ftelescope/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265497990,"owners_count":23777093,"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-08-06T18:03:06.513Z","updated_at":"2025-07-16T08:46:17.779Z","avatar_url":"https://github.com/norman.png","language":"Lua","funding_links":[],"categories":["Lua","资源","Resources"],"sub_categories":["Testing"],"readme":"# Telescope\n\nTelescope is a highly customizable test library for Lua that allows for\ndeclarative tests with nested contexts.\n\n## Features\n\n* Compatible with Lua 5.1 and 5.2.\n* Nestable test contexts/descriptions.\n* [BDD](http://en.wikipedia.org/wiki/Behavior_Driven_Development)-style spec names.\n* Before/after functions per context.\n* Integrated code coverage reports using [Luacov](http://luacov.luaforge.net/).\n* You can easily add your own assertions.\n* Many different formatting options for tests and reports.\n* Simple, well documented API makes it easy to extend/hack.\n* Command line runner allows you to input Lua snippet callbacks, so you can, for example,\n  drop to a debugger on failed tests, or wrap test calls around a profiler, etc.\n\n## An Example\n\n    context(\"A context\", function()\n      before(function() end)\n      after(function() end)\n      context(\"A nested context\", function()\n        test(\"A test\", function()\n          assert_not_equal(\"ham\", \"cheese\")\n        end)\n        context(\"Another nested context\", function()\n          test(\"Another test\", function()\n            assert_greater_than(2, 1)\n          end)\n        end)\n      end)\n      test(\"A test in the top-level context\", function()\n        assert_equal(3, 1)\n      end)\n    end)\n\n## Getting it\n\nYou can install Telescope using Luarocks:\n\n    sudo luarocks install telescope\n\nYou can also check out the source code from Git, and  install via \"make\" if you\nprefer:\n\n    git clone git://github.com/norman/telescope.git\n    cd telescope\n    make install\n\n## Running your tests\n\nTelescope comes with a command-line test runner named `tsc`. Simply run:\n\n    tsc my_test_file.lua\n\nOr perhaps\n\n    tsc -f test/*.lua\n\nThe full test output (what you get using \"-f\") from the examples given would be:\n\n    ------------------------------------------------------------------------\n    A context:\n    A nested context:\n      A test                                                             [P]\n      Another nested context:\n        Another test                                                     [P]\n    A test in the top-level context                                      [F]\n    ------------------------------------------------------------------------\n    A test with no context                                               [U]\n    Another test with no context                                         [U]\n    ------------------------------------------------------------------------\n    This is a context:\n    This is another context:\n      this is a test                                                     [U]\n      this is another test                                               [U]\n      this is another test                                               [U]\n    ------------------------------------------------------------------------\n    8 tests 2 passed 3 assertions 1 failed 0 errors 5 unassertive 0 pending\n\n    A test in the top-level context:\n    Assert failed: expected '3' to be equal to '1'\n    stack traceback:\n      ...ib/luarocks/rocks//telescope/scm-1/lua/telescope.lua:139: in function 'assert_equal'\n      example.lua:18: in function \u003cexample.lua:17\u003e\n      [C]: in function 'pcall'\n      ...ib/luarocks/rocks//telescope/scm-1/lua/telescope.lua:330: in function 'invoke_test'\n      ...ib/luarocks/rocks//telescope/scm-1/lua/telescope.lua:362: in function 'run'\n      ...usr/local/lib/luarocks/rocks//telescope/scm-1/bin/ts:147: in main chunk\n      [C]: ?\n\nTelescope tells you which tests were run, how many assertions they called,\nhow many passed, how many failed, how many produced errors, how many provided\na name but no implementation, and how many didn't assert anything. In the event\nof any failures or errors, it shows you stack traces.\n\nYou can customize the test output to be as verbose or silent as you want, and\neasily write your own test reporters - the source is well documented.\n\nYou can pass in snippets of Lua code on the command line to run as callbacks\nfor various test success/failure scenarios, and easily customize the output or\n  use Telescope with other applications.\n\nYou can see all the available command-line options, and some examples by running:\n\n    tsc -h\n\n### More Examples\n\n    -- Tests can be outside of contexts, if you want\n    test(\"A test with no context\", function()\n    end)\n\n    test(\"Another test with no context\", function()\n    end)\n\n    -- Contexts and tests with various aliases\n    spec(\"This is a context\", function()\n      describe(\"This is another context\", function()\n        it(\"this is a test\", function()\n        end)\n        expect(\"this is another test\", function()\n        end)\n        should(\"this is another test\", function()\n        end)\n      end)\n    end)\n\n### Even More Examples\n\n    -- change the name of your test or context blocks if you want something\n    -- different\n    telescope.context_aliases = {\"specify\"}\n    telescope.test_aliases = {\"verify\"}\n\n    -- create your own assertions\n    telescope.make_assertion(\"longer_than\", \"%s to be longer than %s chars\",\n      function(a, b) return string.len(a) \u003e b end)\n    -- creates two assertions: assert_longer_than and assert_not_longer_than,\n    -- which give error messages such as:\n    -- Assertion error: expected \"hello world\" to be longer than 25 chars\n    -- Assertion error: expected \"hello world\" not to be longer than 2 chars\n\n    -- create a test runner with callbacks to show progress and\n    -- drop to a debugger on errors\n    local contexts = telescope.load_contexts(file)\n    local results = telescope.run(contexts, {\n     after = function(t) io.stdout:write(t.status_label) end,\n     error = function(t) debug.debug() end\n    })\n\n    -- call \"tsc\" on the command line with a callback to generate a custom report\n    tsc --after=\"function(t) print(t.status_label, t.name, t.context) end\" example.lua\n\n## Author\n\n[Norman Clarke](mailto:norman@njclarke.com)\n\nPlease feel free to email me bug reports or feature requests.\n\n## Acknowledgements\n\nTelescope's initial beta release was made on Aug 25, 2009 - the 400th\nanniversary of the invention of the telescope.\n\nThanks to [ScrewUnit](http://github.com/nathansobo/screw-unit/tree/master),\n[Contest](http://github.com/citrusbyte/contest) and\n[Luaspec](http://github.com/mirven/luaspec/) for inspiration.\n\nThanks to [Eric Knudtson](http://twitter.com/vikingux) for helping me come up\nwith the name \"Telescope.\"\n\n## License ##\n\nThe MIT License\n\nCopyright (c) 2009-2012 [Norman Clarke](mailto:norman@njclarke.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorman%2Ftelescope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnorman%2Ftelescope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorman%2Ftelescope/lists"}