Search code examples
unit-testingjunitparameterized

When and why should one write parameterized JUnit test cases?


Can someone explain why and when to write parameterized test cases?


Solution

  • Parameterized tests are used in situations where one needs to perform exactly the same test using a large number of different input values.

    A good example might be testing a piece of code that performs a calculation, where you have a large collection of known-correct answers that you would like to test.