title: Java/JUnit - How does testPrintMessage() get called?
body: <p>In the following code, how does method testPrintMessage() get called?  I dont see any code explicitly calling it.</p>
  
  <p>TestRunner.java</p>
  
  <pre><code>import org.junit.runner.JUnitCore;
  import org.junit.runner.Result;
  import org.junit.runner.notification.Failure;
  
  public class TestRunner {
     public static void main(String[] args) {
        Result result = JUnitCore.runClasses(TestJunit.class);
        for (Failure failure : result.getFailures()) {
           System.out.println(failure.toString());
        }
        System.out.println(result.wasSuccessful());
     }
  }
  </code></pre>
  
  <p>TestJunit.java</p>
  
  <pre><code>import org.junit.Test;
  import static org.junit.Assert.assertEquals;
  public class TestJunit {
  
     String message = "Hello World";
     MessageUtil messageUtil = new MessageUtil(message);
  
     @Test
     public void testPrintMessage() {
        assertEquals(message,messageUtil.printMessage());
     }
  }
  </code></pre>
  
  <p>MessageUtil.java</p>
  
  <pre><code>public class MessageUtil {
  
     private String message;
  
     //Constructor
     //@param message to be printed
     public MessageUtil(String message){
        this.message = message;
     }
  
     // prints the message
     public String printMessage(){
        System.out.println(message);
        return message;
     }
  }
  </code></pre>
  
  <p>I tested this code in Eclipse and it works:  </p>
  
  <pre><code>Hello World
  true
  </code></pre>