title: How can I include test classes into Maven jar and execute them?
body: <p>In a Maven project, I have test classes and source classes in the same package, but in different physical locations. </p>
  
  <pre><code>.../src/main/java/package/** &lt;-- application code
  .../src/test/java/package/** &lt;-- test code
  </code></pre>
  
  <p>It's no problem to access the source classes in the test classes,
  but I would like to run a test runner in the main method and access the <code>AllTest.class</code> so that I can create jar and execute my tests.</p>
  
  <pre><code> public static void main(String[] args) {
      // AllTest not found
      Result result = JUnitCore.runClasses(AllTest.class);
      for (Failure failure : result.getFailures()) {
          System.out.println(failure.toString());
      }
      System.out.println(result.wasSuccessful());
  }
  </code></pre>
  
  <p>But it doesn't work as I don't have access to the test code. I don't understand since they are in the same package.</p>
  
  <p><strong>Question</strong>: how can access test classes from application classes? Alternatively, how can Maven package a fat jar including test classes and execute tests?</p>