Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Having a junit run a piece of code for 1 min interval until it returns success  RSS feed

Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I m running tests that calls real API calls. I want to make sure the api endpoint returns 200 before I run the tests. I would want to retry couple of times every few mins if it returns 500 or 503. What is the best way to do this in junit. Any pointers appreciated.
Posts: 13392
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a system test or a unit test? Are you verifying the functionality at the endpoint or that the endpoint is reachable and clients able to receive a response?

If you are just trying to test functionality, then you would be doing yourself a favor by testing at a finer grained level, without the network involved. If you are testing your configuration and infrastructure setup, then use a loop with some kind of counter for number of attempts to connect.
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
global solutions you can do at home or in your backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!