junit Paramaterizing Tests

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

Sometimes you have a test you need to run multiple times, each time with different data. Parameterizing the test allows you to do this in an easy and maintainable way.

Syntax

  • @RunWith(Parameterized.class) //annotation for test class

    @Parameters//annotation for data

Remarks

One benefit to using parameters is that if one set of data fails, execution will just move to the next set of data instead of stopping the whole test.



Got any junit Question?