O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dynamic tests

As we know, in JUnit 3, we identified tests by parsing method names and checking whether they started with the word test. Then, in JUnit 4, we identified tests by collecting methods annotated with @Test. Both of these techniques share the same approach: tests are defined at compile time. This concept is what we call static testing.

Static tests are considered a limited approach, especially for the common scenario in which the same test is supposed to be executed for a variety of input data. In JUnit 4, this limitation was addressed in several ways. A very simple solution to the problem is to loop the input test data and exercising the same test logic (JUnit 4 example here). Following this approach, one test is executed until ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required