title: How to unit test a method that runs into an infinite loop for some input?
body: <p>This question just occurred to my mind and I want to ask this here.</p>
  
  <p>The case is intentional, I just write a loop which runs infinitely. How do I go about unit testing it?</p>
  
  <p>I ask this because, this situation may occur anywhere in the code. Say my method delegates to several other methods, and I want to know</p>
  
  <ul>
  <li>How it ran into an infinite loop</li>
  <li>What set of input caused it</li>
  <li>Call to which method (from this method) has caused this</li>
  </ul>
  
  <p>I have no code written for this. The question is purely for knowledge sake as to what to do if this situation arises in future. Please respond.</p>