{"id":13601375,"url":"https://github.com/boraelci/java-test-genie","last_synced_at":"2025-04-11T04:30:49.203Z","repository":{"id":157267320,"uuid":"628451279","full_name":"boraelci/java-test-genie","owner":"boraelci","description":"A command-line tool for AI-driven unit test generation","archived":false,"fork":false,"pushed_at":"2023-05-05T13:53:04.000Z","size":2517,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T21:03:10.533Z","etag":null,"topics":["ai","cli","generation","llm","unit-testing"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/java-test-genie","language":"Jupyter Notebook","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/boraelci.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-04-16T01:33:49.000Z","updated_at":"2024-10-15T06:17:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"f864927a-92e3-4293-b5ee-16d6720bc2e1","html_url":"https://github.com/boraelci/java-test-genie","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boraelci%2Fjava-test-genie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boraelci%2Fjava-test-genie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boraelci%2Fjava-test-genie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boraelci%2Fjava-test-genie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boraelci","download_url":"https://codeload.github.com/boraelci/java-test-genie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248147808,"owners_count":21055546,"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","cli","generation","llm","unit-testing"],"created_at":"2024-08-01T18:01:01.682Z","updated_at":"2025-04-11T04:30:48.762Z","avatar_url":"https://github.com/boraelci.png","language":"Jupyter Notebook","funding_links":[],"categories":["cli"],"sub_categories":[],"readme":"# JavaTestGenie\n[![MIT License](https://img.shields.io/github/license/boraelci/java-test-genie)](https://github.com/boraelci/java-test-genie/blob/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/java-test-genie)](https://pypi.org/project/java-test-genie/)\n\n## Demo\nClick on the image to watch the video\n[![Video](https://github.com/boraelci/java-test-genie/blob/main/genie/images/video-thumbnail.png)](https://drive.google.com/file/d/1W8TnxP7CN2rSFGRzgUXU7qNrg4EGsbIk/view?usp=share_link)\n\n## Installation\n\n```bash\npip install java-test-genie\n```\n\n## Usage\n\nBefore running `genie`, set your OpenAI API key with `export OPENAI_API_KEY=\u003cAPI-KEY-HERE\u003e`. You can obtain it at https://platform.openai.com/account/api-keys\n\nEnsure that you are in a at the same level with `src/` when running the tool.\n\nYou need to create a config file named `.genie.json` within your java repository. This file should be at the same level with `src/` as well as where you will run `genie`. In this file, you can specify which directories \u0026 files to include and exclude. The example below includes the `service/` directory but excludes `service/interface`. Similarly, you can specify file names.\n\n```json\n{\n  \"include\": [\n    {\n      \"parent_dir\": \"src/main/java/com/ase/restservice\",\n      \"dir_names\": [\"service\"],\n      \"file_names\": []\n    }\n  ],\n  \"exclude\": [\n    {\n      \"parent_dir\": \"src/main/java/com/ase/restservice\",\n      \"dir_names\": [\"service/interface\"],\n      \"file_names\": []\n    }\n  ]\n}\n```\n\nThe file is case-sensitive. Ensure that you do not list files in the \"exclude\" section unless they already match a path in the \"include\" section. Excluding a path will delete all matches, even if a specific class is explicitly listed in the \"include\" section. For instance, if you exclude \"model/\" but include \"model/Account.java\", it will not work. Instead, simply include \"model/Account.java\" and leave the \"exclude\" section empty, as the \"model/\" directory is already skipped.\n\nFinally, you can run it with:\n\n```bash\ngenie\n```\n\n## Example\nHere is an example repo that you can use the config file above with.\n\n```bash\ngit clone https://github.com/boraelci/kaiserschmarrn.git\n```\n\n## Arguments\n\n1. `--help`: Displays the help message and lists all available arguments.\n2. `--mode`: Allows you to switch between two modes:\n   - `methods` (default): Generates test methods for individual methods within the input class. This mode is suitable for large input classes.\n   - `classes`: Generates a complete test class, including imports, package name, and setup. This mode provides more comprehensive functionality but is not suitable for large input classes. If the input class is too large, you may encounter an error like `Error: this file is too large`.\n   \n3. `--do_overwrite`: Enables automatic overwriting of existing test files without asking for confirmation. By default, this is set to false to protect existing test files. To enable automatic overwriting, just include `--do_overwrite` without specifying a parameter.\n\n4. `--batch-size`: Specifies the number of methods to process at the same time. It defaults to 15, but you can adjust this value based on your requirements.\n\n## Limitations\n\nCurrently, only 1 class per Java file is supported. The tool may produce errors if you supply a path that corresponds to a file with more than 1 class in it.\n\n## Grammar\n\nParsing Java files with the Tree-sitter library requires grammar files. They were obtained in the following way for this tool.\n\n### For macOS\n\n```bash\ngit clone https://github.com/tree-sitter/tree-sitter-java.git\ncd tree-sitter-java\ntree-sitter generate\ngcc -shared -o libtree-sitter-java.dylib -Isrc src/parser.c\n```\n\n### For Windows\n\nUsed the one provided as [`java-grammar.so`](https://github.com/microsoft/methods2test/blob/main/scripts/java-grammar.so)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboraelci%2Fjava-test-genie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboraelci%2Fjava-test-genie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboraelci%2Fjava-test-genie/lists"}