ResolutionContext
class
The ResolutionContext
class provides the core mechanism for generating test data. While it is used internally by AutoParams, you can also instantiate and use it directly in your own test code when needed.
Here's an example:
- Java
- Kotlin
@Test
void testMethod() {
ResolutionContext context = new ResolutionContext();
Product product = context.resolve();
Review review = context.resolve();
}
@Test
fun testMethod() {
val context = ResolutionContext()
val product = context.resolve<Product>()
val review = context.resolve<Review>()
}
In this example, ResolutionContext
is used to manually generate instances of Product
and Review
outside of the @AutoParams
annotation. This offers more control and flexibility for writing custom test logic or handling special cases.