cancel
Showing results for 
Search instead for 
Did you mean: 

How to Cover a while loop in a Junit?

Former Member
0 Kudos

Hi All,

I am facing difficulty in covering a while loop using a Junit. Please find the below piece of code:

while (dateUtils.compareDates(pagBegTime, apiEndTime) && !JobStatus.STOPPED.equals(manageAPIData.getJobStatus()))

dateUtils.compareDates- returns true if pagBegTime is less than apiEndTime. !JobStatus.STOPPED.equals(manageAPIData.getJobStatus()- return true if jobstatus is other than Stopped.

Thanks in Advance.

former_member620692
Active Contributor
0 Kudos

Hi - you can check https://stackoverflow.com/questions/32390767/junit-for-a-method-with-while-loop which has a similar requirement.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

- I tried it and it didn't worked for me.Could you please provide me an alternative solution for me.