Junit allows us to create parametrized tests. Parametrized test class has to be annotated with the @RunWith(Parameterized.class). The parametrized test class also meets below requirements:

  • It is annotated with @RunWith(Parameterized.class).
  • It has a single constructor that contains the test data.
  • It has a static method which annotated with @parameters annotation and generates and returns test data. Each test data is used as parameter for the test method.
  • It needs a test method that annotated with @test annotation.

Class Under Test: Addition.java


It is also possible to inject data values directly into fields without needing a constructor using the @Parameter annotation.




  • You learned how to write parametrized tests with constructor and without constructor.
  • You practiced with parametrized test examples.


JUnit, parametrized tests, unit testing, test framework