title: include test in source file java
body: <p>I Want to write my unit test in the same source file being tested (like you can do in D <a href="http://dlang.org/unittest.html" rel="nofollow">http://dlang.org/unittest.html</a>).</p>
  
  <p>I also want to be able to run the test in eclipse as i usually do with a dedicated test file.</p>
  
  <p>In this example Junit complains if there is no public zero argument constructor:</p>
  
  <pre><code>public class Dummy {
      private String _name;
  
      public Dummy(String name) {
          _name = name;
      }
  
      public String name () {
          return _name;
      }
  
      @Test
      public void testName() throws Exception {
          assertEquals("dummy", new Dummy("dummy").name());
      }
  }
  </code></pre>
  
  <p>Any suggestions on how to put the test method in the "real" source code and be able to run the test (in other words how to fool the no arg constructor restriction)?</p>
  
  <p>Thanks</p>