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

@CsvSource and @CsvFileSource

Another way to specify the source of arguments for parameterized tests is using comma-separated values (CSV). This can be done using the annotation @CsvSource, which allows to embed CSV content as String in the value of the annotation.

Consider the following example. It contains a Jupiter parameterized test (named testWithCsvSource), which is using the annotation @CsvSource. This annotation contains an array of Strings. In each element of the array, we can see there is a different value separated by commas.

The content of the CSV is automatically converted to String and int. To find out more about the implicit type conversion made in parameters by JUnit 5, take a look to the section Argument conversion in this ...

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