captureDynamicTest

fun <R> captureDynamicTest(displayName: String, block: () -> R): DynamicTest

Captures a dynamic test and wraps any AssertionError with OrchestrationError for improved stack traces.

This function creates a DynamicTest that executes the provided block. If an AssertionError occurs during execution, it is wrapped in an OrchestrationError that includes both the orchestration stack trace and the execution stack trace, aiding in debugging test failures.

Example usage:

val test = captureDynamicTest("Validate User Creation") {
val user = createUser()
assertNotNull(user.id)
assertEquals("John", user.name)
}

Return

A DynamicTest instance that can be executed by JUnit.

Parameters

displayName

The display name for the dynamic test.

block

The test logic to execute, which may throw an AssertionError.

Throws

If an AssertionError occurs during test execution, wrapped with enhanced stack traces.