RSS DZone Java Zone

Using Spring AI With LLMs To Generate Java Tests

The AIDocumentLibraryChat project has been extended to generate test code (Java code has been tested). The project can generate test code for publicly available GitHub projects. The URL of the class to test can be provided then the class is loaded, the imports are analyzed and the dependent classes in the project are also loaded. That gives the LLM the opportunity to consider the imported source classes while generating mocks for tests. The testUrl can be provided to give an example to the LLM to base the generated test. The granite-code and deepseek-coder-v2 models have been tested with Ollama. The goal is to test how well the LLMs can help developers create tests.
dzone.com
dzone.com
Create attached notes ...