Logging for Object Resolution
AutoParams provides detailed logging capabilities that help you understand how objects are being resolved during test execution. The resolution log is printed to standard output during test execution, making it easy to trace how each value is generated.
For example, resolving a User
class now produces a detailed trace. Given the following class:
- Java
@AllArgsConstructor
@Getter
public class User {
private final UUID id;
private final String email;
private final String username;
}
Running the following code:
- Java
ResolutionContext context = new ResolutionContext();
User user = context.resolve();
Will print a hierarchical visualization of the resolution process:
> Resolving for: class your.app.User
|-- > Resolving for: interface autoparams.generator.ConstructorResolver
| |-- > Resolving for: interface autoparams.generator.ConstructorExtractor
| | < Resolved(<1 ms): autoparams.generator.DefaultConstructorExtractor@5807ea46 for: interface autoparams.generator.ConstructorExtractor
| < Resolved(<1 ms): autoparams.generator.CompositeConstructorResolver@305289b3 for: interface autoparams.generator.ConstructorResolver
|
|-- > Resolving for: Parameter java.util.UUID id
| < Resolved(<1 ms): 2c792f91-2fb8-41c0-a7af-5bda64192949 for: Parameter java.util.UUID id
|
|-- > Resolving for: Parameter java.lang.String email
| |-- > Resolving for: class autoparams.generator.EmailAddressGenerationOptions
| | < Resolved(<1 ms): EmailAddressGenerationOptions[domains=["test.com"]] for: class autoparams.generator.EmailAddressGenerationOptions
| < Resolved(1 ms): bab83e7b-bb56-4acb-aef4-ee7b4db24121@test.com for: Parameter java.lang.String email
|
|-- > Resolving for: Parameter java.lang.String username
| < Resolved(<1 ms): username24cbc137-4990-414b-9af7-39ae7ce1b437 for: Parameter java.lang.String username
< Resolved(1 ms): your.app.User@33e4068 for: class your.app.User
The log uses the following symbols to represent the resolution flow:
>
indicates the start of a resolution attempt|--
shows nested resolution steps<
indicates successful resolution- Indentation levels represent the depth of the resolution chain
This logging is particularly valuable when working with:
- Customizations
- Complex object hierarchies
- Dependency injection scenarios
- Debugging test failures related to object generation