ai-tests
is a tool designed to assist developers in generating initial test boilerplates. It generates an initial batch of tests using LLMs based on a code file.
Although it's not always perfect, it could save you a ton of time and effort. It can provide a solid starting point for simple test suites, sometimes even generating fully working test suites on the first try!
AI-Tests uses PolyFact to generate AI responses. PolyFact is a managed backend, it abstract from the client all the hassle of managing different APIs, models, databases, etc...
To use it, you need to get a PolyFact token.
Follow these steps to get your PolyFact token:
- Go to https://app.polyfact.com.
- Connect with GitHub.
- Copy the token.
Then, you need to export the PolyFact token in your environment:
export POLYFACT_TOKEN=<your_polyfact_token>
To use ai-tests
, pass the file path to the command as follows:
$ npx ai-tests <input_file>
The output will be a batch of tests in the programming language corresponding to the input file. You can then modify and add to these tests as needed.
The generated tests are by no means a replacement for manually written, thoughtful test cases. The quality of tests varies - sometimes they are perfect and ready to run, and other times they serve as a starting point for further refinement. In general, be a good engineer, use the right tool for the right job.
Also, the tool currently has a limitation on file size. If a file is too large, it will generate multiple tests and concatenate them, which is, depending on the language, not always a good way of generating syntaxically valid test files.
Of course, contributions or suggestions are always welcome! Feel free to submit a pull request or open an issue.