HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

How to write a Data Driven Test in JUnit 4 - Parameterized Unit Test

5,749 views July 13, 2020 10:36

Watch on YouTube
ChannelEvilTester - Software Testing

Description from the creator

This video demonstrates converting a JUnit test into a Parameterized data driven test.

In JUnit 4 to create a parameterized test we:

- annotate the test class with `@RunWith(Parameterized.class)`
- create a static method to provide the data
- this method should be annotated with `@Parameterized.Parameters`
- the method providing data should return a collection of object arrays
- we can provide a name attribute for the parameter method which dynamically changes the display name of the test
- our test class needs a constructor to setup the data when called by JUnit Runner
- our test methods do not take parameters but they all use the same data provided by the constructor

An explanatory blog post with links to the source code is here:

- eviltester.com/post/junit/junit-4-parameterized…

---

Remember to subscribe to this YouTube channel.

You can support me on Patreon patreon.com/eviltester (watch my videos ad free and receive extra content)

I blog at eviltester.com/blog

Learn more about my books and online training at:

- eviltester.com

Follow me on:

- twitter.com/eviltester
- instagram.com/eviltester
- facebook.com/eviltester

About this tutorial

EvilTester - Software Testing published this 10:36 video tutorial on July 13, 2020. It has been watched 5,749 times on YouTube.

Duration
10:36
Published
July 13, 2020
Views
5,749
Likes
82

Tags

Share

This tutorial in other languages