title: How to test a method that never returns?
body: <p>How can I test method behaviour of my class?</p>
  
  <pre><code>public class InfiniteWhileLoop {
      public void fun() {
          while (true) {
              // some code to test
          }
      }
  }
  </code></pre>
  
  <p>I need to test method <code>fun</code> and make sure that it set the field to "xyz". The problem is I get an infinite loop. So I need to run while loop and let it to set the field and after that stop the loop.</p>
  
  <p>Is it possible?</p>