Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Testing and the fly likes Run a JUnit 4 test repeatedly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Run a JUnit 4 test repeatedly " Watch "Run a JUnit 4 test repeatedly " New topic

Run a JUnit 4 test repeatedly

Jakub Drzazga
Ranch Hand

Joined: Nov 14, 2008
Posts: 41
I would like to run single test many times. How can I do it?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

With the exact same data? Why? To test threading or something else? (The answers influence approach which is why the answer comes with questions.)

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

Or perhaps the same test with different inputs and expected results each time?

Parameterizing test cases, Looking for a best practice to deal with numerous similar JUnit Test Cases, JUnit Parameterized API with examples.

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
xsunil kumar
Ranch Hand

Joined: Dec 14, 2009
Posts: 137
Can you try maven to do this job. Maven can invoke junit by using command line. What i will suggest, create one shell script ( in linux) or batch file( in windows), write a code to run the script number of times what you want. in script you can write maven command to invoke junit.

Hope this will help you.
I agree. Here's the link:
subject: Run a JUnit 4 test repeatedly
It's not a secret anymore!