Replace JUnit Timeout Annotation Property with assertTimeout

Replace JUnit Timeout Annotation Property with assertTimeout

#jSparrow adds this new rule to help migrating to JUnit 5!

Rule: Replace JUnit Timeout Annotation Property with assertTimeout

The JUnit Jupiter API provides timeout assertions, i.e., assertions that make sure an executable completes before a timeout is exceeded.

In JUnit 4 this is achieved by using annotation properties, e.g., @Test(timeout=...).

This rule removes the timeout annotation property and inserts an assertTimeout instead. For example, the following test case:

Es wurde kein Alt-Text für dieses Bild angegeben.

is refactored to:

Es wurde kein Alt-Text für dieses Bild angegeben.

This brings jSparrow to a total of 91 automatic refactoring rules.

Find out more information in the Release Notes for jSparrow Eclipse and jSparrow Maven!

"With good program architecture debugging is a breeze, because bugs will be where they should be."

― David May

Happy Coding!


To view or add a comment, sign in

More articles by Michaela Prehofer

Explore content categories