{"id":19312263,"url":"https://github.com/adaiasmagdiel/leste","last_synced_at":"2025-02-24T03:43:05.376Z","repository":{"id":239621365,"uuid":"799965112","full_name":"AdaiasMagdiel/Leste","owner":"AdaiasMagdiel","description":"Leste is a powerful and user-friendly comprehensive Lua testing framework heavily inspired by PestPHP and pytest, aiming to simplify and streamline your testing process.","archived":false,"fork":false,"pushed_at":"2024-06-13T14:49:04.000Z","size":1104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-06T02:28:34.546Z","etag":null,"topics":["elegant","framework","lua","testing","tools","unit-testing"],"latest_commit_sha":null,"homepage":"https://adaiasmagdiel.github.io/Leste/","language":"Lua","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/AdaiasMagdiel.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":"2024-05-13T12:53:27.000Z","updated_at":"2024-06-13T14:48:26.000Z","dependencies_parsed_at":"2024-05-13T17:46:50.952Z","dependency_job_id":"e762921d-e009-4287-842b-b1bda7acf624","html_url":"https://github.com/AdaiasMagdiel/Leste","commit_stats":null,"previous_names":["adaiasmagdiel/leste"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaiasMagdiel%2FLeste","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaiasMagdiel%2FLeste/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaiasMagdiel%2FLeste/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdaiasMagdiel%2FLeste/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdaiasMagdiel","download_url":"https://codeload.github.com/AdaiasMagdiel/Leste/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240415211,"owners_count":19797599,"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":["elegant","framework","lua","testing","tools","unit-testing"],"created_at":"2024-11-10T00:33:53.974Z","updated_at":"2025-02-24T03:43:05.348Z","avatar_url":"https://github.com/AdaiasMagdiel.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./assets/banner.png\" width=\"600\" alt=\"Leste - Your Powerfull Lua Test Framework\"\u003e\n    \u003cp align=\"center\"\u003e\n        \u003ca href=\"https://www.lua.org/\"\u003e\u003cimg alt=\"Lua Language\" src=\"https://img.shields.io/badge/Language-Lua-blue?style=flat\u0026logo=lua\u0026logoColor=white\"\u003e\u003c/a\u003e\n        \u003ca href=\"./LICENSE\"\u003e\u003cimg alt=\"Project's License\" src=\"https://img.shields.io/badge/License-MIT-brightgreen\"\u003e\u003c/a\u003e\n    \u003c/p\u003e\n\u003c/p\u003e\n\n---\n\nLeste is a powerful and user-friendly Lua testing framework heavily inspired by PestPHP and pytest, aiming to simplify and streamline your testing process.\n\nJust like a compass guides you in the right direction, Leste serves as a guiding tool for your tests, ensuring that you stay on the right path to successful testing practices.\n\nThe name Leste cleverly merges Lua (L) and teste (Portuguese for test), embodying the playful essence of its creation. Additionally, the word \"leste\" in Portuguese carries the meaning of \"east\". This serving as a subtle homage to Lua's Brazilian roots.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./assets/preview.png\" width=\"600\" alt=\"output of Leste cli\"\u003e\n    \u003cbr\u003e\n    \u003csmall\u003eLeste can provide visually appealing error reports to streamline your workflow.\u003c/small\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n  + [Installing Leste with LuaRocks](#installing-leste-with-luarocks)\n    + [Ensuring Leste Accessibility](#ensuring-leste-accessibility)\n  + [Installing Leste by cloning this repository](#installing-leste-by-cloning-this-repository)\n- [Usage](#usage)\n  + [Command Syntax](#command-syntax)\n  + [Arguments](#arguments)\n  + [Options](#options)\n  + [Examples](#examples)\n- [Writing Tests](#writing-tests)\n  + [1. Create a Tests Folder](#1-create-a-tests-folder)\n  + [2. Create Test Files](#2-create-test-files)\n  + [3. Write Test Cases](#3-write-test-cases)\n  + [4. Run Tests](#4-run-tests)\n  + [Example Test Execution](#example-test-execution)\n- [Contribution](#contribution)\n- [License](#license)\n\n## Features\n\nLeste offers the following features:\n\n1. **Assertion Tracking**: Leste tracks the total number of assertions made during tests.\n2. **Verbose Output**: Choose whether to display the output of the print function inside tests.\n3. **Exit on First Failure**: Option to stop running tests after the first failure.\n4. **Test Case Organization**: Easily organize test cases with beforeAll, afterAll, beforeEach, and afterEach hooks.\n5. **CLI Interface**: Provides a CLI interface for running tests from the command line.\n6. **Flexible Test Case Definition**: Define test cases using the `it` function, specifying a description and test function.\n7. **Initialization and Cleanup**: Initializes the testing framework and cleans up after test execution.\n8. **Detailed Test Reports**: Generates detailed test reports including test outcomes, execution time, assertions, and errors.\n9. **Configurable Output**: Customize the output format based on verbosity settings.\n10. **Integration with Lua Modules**: Seamlessly integrate Leste with Lua modules for testing Lua code.\n\nWith Leste, you can streamline your testing process and ensure the reliability of your Lua applications.\n\n## Installation\n\nYou can install Leste using luarocks or cloning this repository, choose the best option that fits you.\n\n### Installing Leste with LuaRocks\n\nLeste is conveniently available through LuaRocks, the Lua package manager. If you already have LuaRocks installed, you can easily install Leste with the following command:\n\n```bash\nluarocks install leste\n```\n\nThis command will automatically download Leste from the LuaRocks repository and generate the `leste` script for you. This script enables you to run Leste directly from your command line.\n\n#### Ensuring Leste Accessibility\n\nTo ensure you can execute Leste from any directory in your terminal, you need to add the LuaRocks bin directory to your system's PATH environment variable. This PATH variable defines the locations your system searches for executable programs.\n\nBy default, LuaRocks installs command-line scripts like `leste` in a specific directory depending on your installation type:\n\n- **System-wide Installation:** `/usr/local/bin`\n- **Per-user Installation:**\n    - `~/.luarocks/bin` (on Unix-like systems)\n    - `%APPDATA%/luarocks/bin` (on Windows)\n\n### Installing Leste by cloning this repository\n\n1. Clone the repository from GitHub:\n   ```bash\n   git clone https://github.com/AdaiasMagdiel/Leste.git\n   ```\n\n2. Navigate into the Leste directory:\n   ```bash\n   cd Leste\n   ```\n\n3. Create a script named `leste` (or `leste.bat` for Windows) pointing to the `leste/main.lua` file:\n   - For Unix-like systems (Linux, macOS):\n     ```bash\n     #!/bin/bash\n\n     lua path/to/leste/main.lua $*\n     ```\n   - For Windows:\n     ```cmd\n     @echo off\n\n     lua path\\to\\leste\\main.lua %*\n     ```\n\n4. Ensure the script is added to your system's PATH so it can be executed from anywhere.\n\n## Usage\n\nLeste provide a CLI interface for running tests using the testing framework.\n\n### Command Syntax\n\n```bash\nleste [options] [file/folder...]\n```\n\n### Arguments\n\n- `file`: File (or files) with tests to run.\n- `folder`: Folder (or folders) to find tests, default is `./tests`.\n\n### Options\n\n- `-d, --disable-color`: Disable color for the output, print raw text. Default is `false`.\n- `-h, --help`: Show the usage message and exit.\n- `-v, --verbose`: Display output of print function inside tests. Default is `false`.\n- `-x, --exitfirst`: Exit on the first failure. Default is `false`.\n\n### Examples\n\nRun tests located in the default `./tests` folder with verbose output:\n\n```bash\nleste -v\n```\n\nRun tests located in a specific folder:\n\n```bash\nleste my_tests_folder\n```\n\nStop the tests after the first failure:\n\n```bash\nleste -x\n```\n\nTo disable colors in the output, use the `-d` or `--disable-color` flags.\n\n```bash\nleste -d\n```\n\n## Writing Tests\n\n### 1. Create a Tests Folder\n\nFirst, create a folder named `tests` in your project directory. This folder will contain all your test files.\n\n```bash\nmkdir tests\n```\n\n### 2. Create Test Files\n\nInside the `tests` folder, create a Lua file for each set of tests you want to write. Ensure that each test file has a filename prefix of \"test\" so that Leste can discover and execute them. For example, `testExample.lua`.\n\n### 3. Write Test Cases\n\nIn each test file, you can define multiple test cases using the `Leste.it` function. Each test case consists of a description and a function containing the test assertions.\n\nHere's an example of a valid test file (`testExample.lua`):\n\n```lua\nlocal Leste = require(\"leste.leste\")\n\n-- Test case 1: A basic example\nLeste.it(\"Remember to write an interesting and well-explained description about the test.\", function()\n    assert(true)\nend)\n\n-- Test case 2: Using print statements for debugging\nLeste.it(\"You can add print statements if you need to debug, but remember to use the -v flag.\", function()\n    print(\"This message will appear in the test standard output.\")\n    assert(true)\nend)\n```\n\n\u003e [!TIP]\n\u003e Utilizing Lua's `assert` function is an effective method for asserting your tests. For more detailed output, consider utilizing the `leste.assertions` module. This module offers a range of assert functions that are adept at handling errors more efficiently.\n\n### 4. Run Tests\n\nTo execute the tests, use the Leste CLI interface. Navigate to your project directory in the terminal and run the following command:\n\n```bash\nleste -v\n```\n\nThis command will automatically run all the test files (`test*`) located in the `tests` folder. You can also specify a specific folder to run tests from if needed.\n\nTry to run the code without the verbose flag to observe how the print function is silenced.\n\n```bash\nleste\n```\n\n### Example Test Execution\n\nAfter running the tests, you will see the test results displayed in the terminal, including passed and failed tests, execution time, and any assertions errors, general errors or debug output.\n\n```bash\n    PASS   Remember to write an interesting and well-explained description about the test.\n\n    File:    testExample.lua\n    Time:    0.00s\n    Asserts: .\n\n    PASS   You can add print statements if you need to debug, but remember to use the -v flag.\n\n    File:    testExample.lua\n    Time:    0.00s\n    Asserts: .\n\nSTDOUT:\nThis message will appear in the test standard output. \n\n\n    ✓ All tests passed successfully\n\n    Tests:      2 tests    2 passed    0 failed    (2 assertions)\n    Duration:   0.00s\n```\n\n## Contribution\n\nContributions are welcome Please feel free to submit pull requests or open issues for any bugs or feature requests.\n\nYou can start selecting a task from the list in the [TODO.md](TODO.md) file.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaiasmagdiel%2Fleste","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadaiasmagdiel%2Fleste","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadaiasmagdiel%2Fleste/lists"}