Generating unit tests automatically with large language models

Client
Zürcher Kantonalbank
Industry
Financial services
Capability
Software & AI
Year
2023

A proof of value shows that a language model with retrieval-augmented generation writes unit tests live for the bank's code.

The challenge

At Zürcher Kantonalbank, almost two thirds of the lead time in the change process went into testing and acceptance. Good tools for this repetitive work were missing.

Our approach

We compared code-based language models and fine-tuning methods, built a pipeline to collect data from open-source Java repositories and fine-tuned CodeLlama.

A retrieval-augmented system fetches the relevant code context and creates the prompts automatically.

The impact
  • Working prototype on ZKB's code base
  • Unit tests for any code, with GPT-4 or the fine-tuned model
  • Basis for faster bug detection and higher test coverage

Related client impact

All case studies

Facing a similar challenge?

Discuss your challenge