Testing tooling

JUnit assertTimeout

Checks elapsed execution time without preemptively interrupting the calling thread. Framework or debugger behavior source-reviewed; actual tool execution NOT RUN.

Formal Syntax & Structure

java syntaxjava
assertTimeout(Duration.ofSeconds(2), executable)

Working Example

Example Snippetjava
package example.books;
import org.junit.jupiter.api.Test;import java.time.Duration;import static org.junit.jupiter.api.Assertions.*;
class BudgetTest {    @Test    void finiteCalculation() {        assertTimeout(Duration.ofSeconds(2),                () -> assertEquals(34, Receipt.totalCents(2, 17)));    }}
Java Reference