Approvals uses the stack trace to figure out the name of the .approved. file.
Dynamic tests require some intervention to capture this at the right time.
Because of this, you will always have to use the Options when calling verify() as well.
Here is an example of how to do this in Java:
@TestFactory
Collection<DynamicTest> testFactory3()
{
return Stream.of(1, 2).map(number -> JupiterApprovals.dynamicTest("test " + number,
o -> Approvals.verify("content for " + number, o))).collect(Collectors.toList());
}Here is an example of how to do this in Kotlin:
@TestFactory
fun `test factory`(): List<DynamicTest> {
return listOf(1, 2).map { it ->
JupiterApprovals.dynamicTest("square $it") {
o -> Approvals.verify("${it}^2 = ${it * it}", o)
}
}
}