{"id":13601369,"url":"https://github.com/tsbrandon1010/TestGenie","last_synced_at":"2025-04-11T04:30:59.445Z","repository":{"id":203216753,"uuid":"699116333","full_name":"tsbrandon1010/TestGenie","owner":"tsbrandon1010","description":"Automatically generate unit tests for your code.","archived":false,"fork":false,"pushed_at":"2023-12-06T00:43:22.000Z","size":53943,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-02T18:40:23.292Z","etag":null,"topics":["ai","llm","testing-tool","unit-testing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsbrandon1010.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-10-02T00:30:06.000Z","updated_at":"2024-01-06T02:14:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b01f2fa-d05f-4a87-8d5d-7a5b304c4a94","html_url":"https://github.com/tsbrandon1010/TestGenie","commit_stats":null,"previous_names":["tsbrandon1010/llm-unit-tests"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsbrandon1010%2FTestGenie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsbrandon1010%2FTestGenie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsbrandon1010%2FTestGenie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsbrandon1010%2FTestGenie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsbrandon1010","download_url":"https://codeload.github.com/tsbrandon1010/TestGenie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223458295,"owners_count":17148445,"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":["ai","llm","testing-tool","unit-testing"],"created_at":"2024-08-01T18:01:01.635Z","updated_at":"2025-04-11T04:30:59.437Z","avatar_url":"https://github.com/tsbrandon1010.png","language":"Python","funding_links":[],"categories":["ai"],"sub_categories":[],"readme":"# TestGenie\nAccelerate your test driven development by using the power of AI to automatically write unit tests for your code.\n\n## Getting Started:\n\nAssuming that you have a supported Python installation (3.x), you can start by \ncloning the repository:\n```\ngit clone https://github.com/tsbrandon1010/LLM-Unit-Tests\n```\nOr by downloading the repository as a ZIP file:\n\n![image](https://github.com/tsbrandon1010/TestGenie/assets/15933213/06ccc40d-abbb-40ca-a54f-befde27af3c3)\n\nNext, we can get the required packages:\n\n```\npip install -r requirements.txt\n```\n\n### Using the tool\nAfter downloading the tool and package dependencies, you must create an API key with [OpenAI](https://openai.com/).\n\u003cbr\u003eMore information can be found ***[here](https://elephas.app/blog/how-to-create-openai-api-keys-cl5c4f21d281431po7k8fgyol0)***.\n\n![image](https://github.com/tsbrandon1010/TestGenie/assets/15933213/06aa9532-f3c9-4eba-9ece-69b199374e01)\n\nWithin the ```~/LLM-Unit-Tests/main``` directory, create a file called ```.env```. This is where you will put your OpenAI API key (your key will go within the quotations).\n\n![image](https://github.com/tsbrandon1010/TestGenie/assets/15933213/0ecccdda-63f5-4811-bd2f-d3307d330803)\n\nWe should now be able to use the tool:\n\u003cbr\u003e```python auto_test.py -i \u003cinput\u003e -o \u003coutput\u003e (-r \u003cmax retries\u003e) (-s) -l \u003clanguage\u003e```\n\n**Alternatively, you can use auto_test.exe in the ```/main/``` directory, and skip installing Python and the dependencies.**\n\u003cbr\u003e```auto_test -i \u003cinput\u003e -o \u003coutput\u003e (-r \u003cmax retries\u003e) (-s) -l \u003clanguage\u003e```\n\n\n```-i```: The path of the file for which the tool will generate a unit test.\n\u003cbr\u003e```-o```: A path to the file where the generated unit test will be saved.\n\u003cbr\u003e```-r```: The maximum number of times to re-generate the unit test if the test fails (optional).\n\u003cbr\u003e```-s```: Sparse tests. By default, the program will generate a \nunit test for the entire file that is passed. Include this flag if you would like to\npick and choose the functions to generate tests for (optional). **NOTE: CURRENTLY ONLY SUPPORTS PYTHON**\n\u003cbr\u003e```-l```: Specify whether your language (currently only supports Python and C#). \n\n### Running through examples\nThere is an example program we are going to use called ```is-prime.py``` that is located in ```~/programs/prime-checker/main```\n```\nimport math\ndef is_prime(num: int) -\u003e bool:\n    '''Check if a number (num) is prime or not.'''\n    if num \u003e 1:\n        for i in range(2, int(num/2)+1):\n            if (num % i) == 0:\n                return False\n        else:\n            return True\n    else:\n        return False\n```\n\nTo create a unit test for this simple example, we can do the following:\n\u003cbr\u003e```python auto_test.py -i ~/programs/prime-checker/main/is-prime.py -o ~/programs/prime-checker -r 0```\n\nThe generated test might look like the following:\n```\nimport unittest\nimport math\n\nimport math\ndef is_prime(num: int) -\u003e bool:\n    '''Check if a number (num) is prime or not.'''\n    if num \u003e 1:\n        for i in range(2, int(num/2)+1):\n            if (num % i) == 0:\n                return False\n        else:\n            return True\n    else:\n        return False\n\nclass TestIsPrime(unittest.TestCase):\n    # Test for prime numbers\n    def test_prime_numbers(self):\n        self.assertTrue(is_prime(2))\n    \n    # Test for non-prime numbers\n    def test_non_prime_numbers(self):\n        self.assertFalse(is_prime(0))\n\nif __name__ == '__main__':\n    unittest.main()\n```\n\n### Common Problems:\n**TLDR:** If you want the highest level of accuracy with your generated unit tests, it is recommended that you\nspecify at least 1 retry attempt (```-r 1```).\n\nA common problem with the current version of the test generator is that it will forget to write the function\nyou are testing in the unit test, or attempt to import the function from an invalid path. Setting ```-r``` to a value \u003e 1\nwill normally catch this, but you might have to import or define the function in the generated unit test yourself. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsbrandon1010%2FTestGenie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsbrandon1010%2FTestGenie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsbrandon1010%2FTestGenie/lists"}