Java – JUnit – How to test a method with different values

java, junit, junit4, unit-testing

I have a method and wish to test it with different values. My question is: how can I write a JUnit test that would test the same method with different values?

Best Solution

You can take a look at parametrized tests like in example.

You can also use theories which is more convenient in a lot of cases.