Logging for Object Resolution
AutoParams provides detailed logging capabilities that help you understand how objects are being resolved during test execution. To enable logging, apply the @LogResolution
annotation to your test method alongside @AutoParams
. When enabled, 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 produces a detailed trace. Given the following class:
- Java
- Kotlin
@AllArgsConstructor
@Getter
public class User {
private final UUID id;
private final String email;
private final String username;
}
class User(
private val id: UUID,
private val email: String,
private val username: String
)
Running the following code:
- Java
- Kotlin
@Test
@AutoParams
@LogResolution
void testMethod(User user) {
}
@Test
@AutoKotlinParams
@LogResolution
fun testMethod(user: User) {
}
Will print a hierarchical visualization of the resolution process:
User user (5ms)
├─ UUID id → fbdf7aa8-1af7-4308-bc64-ee9dbfeba8d2 (1ms)
├─ String email → 53bf56a3-8a42-47f3-a5c9-854862ea4a56@test.com (2ms)
└─ String username → usernamec6962921-ab77-4dbc-a71d-6932a9faa5be (1ms)
The log uses a tree structure to show the resolution hierarchy:
- Each level shows the query type and parameter name
→
indicates the generated value- Time taken for each resolution is shown in parentheses
- 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