LLM Input Annotations (Beta)
Diffblue Cover can make use of Large Language Models (LLMs) as a beta feature in order to provide more context-aware inputs to tests. This page describes how to guide the LLM usage.
Using @InTestsUseLLM
@InTestsUseLLMThe @InTestsUseLLM annotation allows you to request inputs from a configured LLM connection in order to provide more creative inputs for tests of a particular method under test. More creative values can often provide cosmetically better tests, but can sometimes lead to improved test strength through better assertions, and potentially improved coverage. See LLM Configuration (Beta) to configure the LLM connection & credentials.
The annotation can be located on a method, class or package to identify the scope of methods under test where LLMs should be consulted. For example the following method validates credit card numbers and is annotated such that the LLM can provide some realistic and valid credit card numbers:
/**
* Validates a credit card number using the Luhn algorithm.
* <p>
* This method sanitizes the input by removing spaces and hyphens,
* then checks if the number passes the Luhn checksum.
* It does not check card type or length.
*
* @param cardNumber the credit card number as a String; spaces and hyphens are allowed
* @return true if the card number is valid according to the Luhn algorithm, false otherwise
*/
@InTestsUseLLM
public static boolean isValidCreditCardNumber(String cardNumber) {
// ...
}Last updated
Was this helpful?

