title: Class<Test> object not the same type as a Test object? Junit
body: <p>I'm trying to write some code which recursively adds TestSuites in a project to a suite of suites located at the root of the package hierarcy. </p>
  
  <p>I've already written the code which returns a Collection object which contains a File object for each Test Suite found in my project. </p>
  
  <p>I'm now trying to loop through them and add them to a TestSuite in a file called AllTests.java:</p>
  
  <pre><code>public static Test suite() throws IOException, ClassNotFoundException {
      TestSuite suite = new TestSuite();
  
              //Code not included for getTestSuites() in this snippet.
      Collection&lt;File&gt; testSuites = getTestSuites();
      for(File f: testSuites) {
  
              //Truncate the path of the test to the beginning of the package name
              String testName = f.getAbsolutePath().substring(f.getAbsolutePath().lastIndexOf("net"));
  
              //Replace backslashes with fullstops
              testName = testName.replaceAll("\\\\", ".");
  
              //Take the .class reference off the end of the path to the class
              testName = testName.replaceAll(".class", "");
  
              //Add TestSuite to Suite of Suites
  
              Class&lt;? extends Test&gt; test = (Class&lt;? extends Test&gt;) AllTests.class.getClassLoader().loadClass(testName);
              suite.addTest(test);
      }
  </code></pre>
  
  <p>Unfortunately I am getting the following compiler error on the suite.addTest(test) line:</p>
  
  <blockquote>
    <p>The method addTest(Test) in the type
    TestSuite is not applicable for the
    arguments (Class &lt; capture#3-of ? extends Test>)</p>
  </blockquote>
  
  <p>Am I making a fundamental mistake by assuming that a Class&lt; Test > reference and a Test reference are one and the same?</p>