0

I would like to run a test multiple times with different parameters and have them displayed as separate tests (with different names) in the Junit report.

Does anyone know a way to do that?

Thanks in advance.

Med Amine
  • 33
  • 1
  • 3
  • Possible duplicate of [Changing names of parameterized tests](https://stackoverflow.com/questions/650894/changing-names-of-parameterized-tests) – Remco Buddelmeijer Oct 03 '19 at 11:29
  • If you are using JUnit 4, please take a look at the duplicate post, otherwise if you are using JUnit 5 take a look at: https://www.baeldung.com/parameterized-tests-junit-5 – Remco Buddelmeijer Oct 03 '19 at 11:29
  • @MedAmine, What version of JUnit you're using? Where do you want your parameters to come from? – M. Prokhorov Oct 03 '19 at 15:24
  • @M. Prokhorov I am using JUnit5 , thanks for you reply i got my answer from the link that you shared about parameterized tests in junit5. thanks – Med Amine Oct 04 '19 at 01:06

1 Answers1

1

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