Help the world stop coronavirus! Stay home!

Prev Next

JUnit / Junit Interview questions III

Explain parameterized tests in Junit.

In Junit 4, a new feature named "parameterized tests" is introduced that allows developer to run the same test repeated for different input values.

Creating parameterized tests using Junit 4 is simple and the steps are as follows.

  • Annotate the Junit test class with @RunWith (Parameterized.class).
  • Create a public static method and annotate with @Parameters that returns a Collection of Object array to be used as test dataset organized into rows and columns.
  • Create a public constructor that accepts one row equivalent of test data as parameter.
  • Create an instance variable for each column/field of a row test data.
  • Create your test cases using the instance variables (columns) as the input test data.

For each row of test data, the test case will be invoked and executed.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

TOSCA

Comments & Discussions