Playback starts YouTube’s embedded player (privacy-enhanced mode).
How to write a Data Driven Test in JUnit 4 - Parameterized Unit Test
ChannelEvilTester - Software TestingDescription 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
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.
- Category
- Science & Technology
- Duration
- 10:36
- Published
- July 13, 2020
- Views
- 5,749
- Likes
- 82
Tags
Share
This tutorial in other languages
- FRComment écrire un test piloté par les données dans JUnit 4 - paramétrés Test Unit
- ESCómo escribir una prueba controlada por datos en JUnit 4 - Prueba de la unidad parametrizada
- PTComo escrever um Test Driven Dados no JUnit 4 - Parameterized Unidade de Teste
- ITCome scrivere un Test Driven dati in JUnit 4 - parametrizzato Unit Test
- DEWie ein Data Driven-Test in JUnit schreiben 4 - Parameterized Einheit Test
- NLHoe maak je een Data Driven Test schrijven in JUnit 4 - Geparametriseerde Unit Test
- RUКак написать Driven Test Data в JUnit 4 - Parameterized Test Unit
- PLJak napisać Driven dane z badań w JUnit 4 - Sparametryzowane jednostka testowa
- JAパラメータ化されたユニットテスト - JUnitの4にデータ駆動型テストの書き方
- ARكيفية كتابة اختبار المستندة إلى البيانات في أداة JUnit 4 - معلمات اختبار وحدة
- HIParameterized यूनिट टेस्ट - JUnit 4 में एक डेटा संचालित टेस्ट लिखने के लिए कैसे
- IDBagaimana menulis Didorong Data Uji di JUnit 4 - Parameterized Unit Uji