Search code examples
javatestingjunitjunit5

Run one junit test multiple times with different parameters


How can I run a test multiple times with different parameters and have them displayed as separate tests (with different names) in the Junit report?


Solution

  • You can create a Java method that runs the code, if not in your JUnit test case then in the Java file you import. Then for each of the tests you want, you just call it repeatedly with different input arguments and different parameters. See the links you've been given: https://www.baeldung.com/parameterized-tests-junit-5