Package gnu.testlet

Examples of gnu.testlet.Testlet


              pr = new PackageResult(packageName);
            classResult = pr.getClassResult(className);
            if (classResult == null)
              classResult = new ClassResult(className);

            Testlet testlet = createTestlet(c, line);
            if (testlet != null) {
                runTestlet(testlet, pr, testName);
            }
        }
        catch (ClassNotFoundException e)
View Full Code Here


   * of {@link Testlet}.
   * @param line The line giving the name of the testlet (used for error reporting).
   * @return an instance of the given testlet.
   */
  protected Testlet createTestlet(Class c, String line) {
      Testlet testlet = null;
      try
      {
        testlet = (Testlet) c.newInstance();
      }
      catch (ClassCastException e)
View Full Code Here

    currentResult = new TestResult(name.substring(12));
    description = name;

    checkPoint(null);

    Testlet t = null;
    try
      {
        Class k = Class.forName(name);
        int mods = k.getModifiers();
        if (Modifier.isAbstract(mods))
          {
            description = NOT_A_TEST_DESCRIPTION;
            return;
          }
       
        Object o = k.newInstance();
        if (! (o instanceof Testlet))
          {
            description = NOT_A_TEST_DESCRIPTION;
            return;
          }
        if (o instanceof VisualTestlet)
          {
            if (! interactive)
              {
                description = NOT_A_TEST_DESCRIPTION;
                return;
              }
          }
        else
          {
            if (interactive)
              {
                description = NOT_A_TEST_DESCRIPTION;
                return;
              }
          }
        t = (Testlet) o;
      }
    catch (Throwable ex)
      {
        description = FAIL_TO_LOAD_DESCRIPTION;
        // Maybe the file was marked not-a-test, check that before we report
        // it as an error
        try
        {
          File f = new File(name.replace('.', File.separatorChar) + ".java");
          BufferedReader r = new BufferedReader(new FileReader(f));
          String firstLine = r.readLine();
          // Since some people mistakenly put not-a-test not as the first line
          // we have to check through the file.
          while (firstLine != null)
            {
              if (firstLine.indexOf("not-a-test") != -1)
                  {
                    description = NOT_A_TEST_DESCRIPTION;
                    return;
                  }
              firstLine = r.readLine();
            }
        }
        catch(FileNotFoundException fnfe)
        {         
        }
        catch (IOException ioe)
        {         
        }
       
        String r = getStackTraceString(ex, "          ");
        currentResult.addException(ex, "failed loading class ", r);
       
        debug(ex);
        if (ex instanceof InstantiationException
            || ex instanceof IllegalAccessException)
          debug("Hint: is the code we just loaded a public non-abstract "
                + "class with a public nullary constructor???");

       
        if (!verbose)
          System.out.println ("FAIL: " + stripPrefix(name)
        + "\n  exception when loading:");
        else
          {
            System.out.println ("TEST: "+stripPrefix(name));
            System.out.println("  FAIL: exception when loading");
          }
        if (exceptions)
          System.out.println(getStackTraceString(ex, "   "));
       
        if (verbose)
          System.out.println("TEST FAILED: exception when loading "
                             + stripPrefix(name));

        if (report != null)
          report.addTestResult(currentResult);

        return;
      }

    // If the harness started okay, now we run the test.
    if (t != null)
      {
        try
          {
            if (verbose)
              System.out.println("TEST: " + stripPrefix(name));
            t.test(this);
            removeSecurityManager();
          }
        catch (Throwable ex)
          {
           
View Full Code Here

                            if (Testlet.class.isAssignableFrom(k)) {
                                if (!quiet) {
                                    System.out.println("Running "
                                        + className);
                                }
                                Testlet t = (Testlet) k.newInstance();
                                PluginTestHarness h = new PluginTestHarness(
                                    t, verbose);
                                t.test(h);
                                passed += h.passed;
                                failed += h.failed;
                                if ((h.failed > 0) && stopOnFail) {
                                    break;
                                }
View Full Code Here

TOP

Related Classes of gnu.testlet.Testlet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.