Examples of JUnitTest


Examples of org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

        }

    if (className == null)
      throw new IllegalArgumentException("Test class name not specified");

    JUnitTest t = new JUnitTest(className);

    // Add/overlay system properties on the properties from the Ant project
    Hashtable p = System.getProperties();
    for (Enumeration _enum = p.keys(); _enum.hasMoreElements();) {
      Object key = _enum.nextElement();
      props.put(key, p.get(key));
    }
    t.setProperties(props);

    EclipseTestRunner runner = new EclipseTestRunner(t, testPluginName, haltError, haltFail);
    transferFormatters(runner);
    runner.run();
    return runner.getRetCode();
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

            return null;
          }
        }
      }

      JUnitTest test = new JUnitTest();
      test.setName(JavaUtils.getFullyQualifiedName(src));
      if (method != null){
        IAnnotation testAnnotation = method.getAnnotation("Test");
        if (testAnnotation == null || !testAnnotation.exists()){
          println(Services.getMessage(
                "junit.testing.test.method.not.annotated",
                method.getElementName()));
          return null;
        }
        test.setMethods(method.getElementName());
      }
      junit.addTest(test);

    }else if (testName != null){
      if (testName.indexOf('*') != -1){
        createBatchTest(javaProject, junit, testName);
      }else{
        JUnitTest test = new JUnitTest();
        test.setName(testName);
        junit.addTest(test);
      }

    }else{
      ArrayList<String> names = new ArrayList<String>();
      IType[] types = JUnitCore.findTestTypes(javaProject, null);
      for (IType type : types) {
        names.add(type.getFullyQualifiedName());
      }
      Collections.sort(names);

      for (String name : names){
        JUnitTest test = new JUnitTest();
        test.setName(name);
        junit.addTest(test);
      }
    }

    try{
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

            {
                BatchTest test = (BatchTest) i.next();
                Enumeration e = test.elements();
                while(e.hasMoreElements())
                {
                    JUnitTest jtest = (JUnitTest) e.nextElement();
                    allTests.add(jtest.getName());
                }
            }
        }

        iterateTests(allTests, props);
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

            int retCode = process.waitFor();

            if (watchDog != null && watchDog.killedProcess())
            {
                JUnitTest test = new JUnitTest(suite);

                try
                {
                    logTimeout((FormatterElement[]) formatters.toArray(new FormatterElement[formatters.size()]), test);
                }
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

        }

    if (className == null)
      throw new IllegalArgumentException("Test class name not specified"); //$NON-NLS-1$

    JUnitTest t = new JUnitTest(className);

    // Add/overlay system properties on the properties from the Ant project
    Hashtable p = System.getProperties();
    for (Enumeration _enum = p.keys(); _enum.hasMoreElements();) {
      Object key = _enum.nextElement();
      props.put(key, p.get(key));
    }
    t.setProperties(props);

    EclipseTestRunner runner = new EclipseTestRunner(t, testPluginName, haltError, haltFail);
    transferFormatters(runner);
    runner.run();
    return runner.getRetCode();
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

            try
            {
                Enumeration tests = getIndividualTests();
                while (tests.hasMoreElements())
                {
                    JUnitTest test = (JUnitTest) tests.nextElement();
                    if (test.shouldRun(getProject())
                     && !theContainer.isExcluded(test.getName()))
                    {
                        if (theContainer.getToDir() != null)
                        {
                            test.setTodir(theContainer.getToDir());
                        }
                        execute(test);
                    }
                }
            }
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

  protected void startTests() {
    final TestSuite suite = new TestSuite();
    final TestResult result = new TestResult();

    final JUnitTest jUnitTest = new JUnitTest("ch.ethz.iks.slp.test");
      jUnitTest.setProperties(System.getProperties());
     
      // create the xml result formatter
    final JUnitResultFormatter xmlResultFormatter = new XMLJUnitResultFormatter();
    final File file = new File(outputDirectory, "TEST-ch.ethz.iks.slp.test" + ".xml");
    try {
      xmlResultFormatter.setOutput(new FileOutputStream(file));
    } catch (FileNotFoundException e) {
      // may never happen
      e.printStackTrace();
    }
    result.addListener(xmlResultFormatter);
    // create a result formatter that prints to the console
    final JUnitResultFormatter consoleResultFormatter = new BriefJUnitResultFormatter();
    consoleResultFormatter.setOutput(System.out);
    result.addListener(consoleResultFormatter);

    // add the actual tests to the test suite
    Collection collection = new ArrayList();
    collection.add(SelfDiscoveryTest.class);
    for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
      Class clazz = (Class) iterator.next();
      // run all methods starting with "test*"
      Method[] methods = clazz.getMethods();
      for (int i = 0; i < methods.length; i++) {
        if (methods[i].getName().startsWith("test")) {
          TestCase testCase;
          try {
            testCase = (TestCase) clazz.newInstance();
            testCase.setName(methods[i].getName());
            suite.addTest(testCase);
          } catch (InstantiationException e) {
            // may never happen
            e.printStackTrace();
          } catch (IllegalAccessException e) {
            // may never happen
            e.printStackTrace();
          }
        }
      }
    }
   
    // prepare to run tests
    final long start = System.currentTimeMillis();
    xmlResultFormatter.startTestSuite(jUnitTest);
    consoleResultFormatter.startTestSuite(jUnitTest);
   
      // run tests
    suite.run(result);
     
    // write stats and close reultformatter
    jUnitTest.setCounts(result.runCount(), result.failureCount(), result.errorCount());
      jUnitTest.setRunTime(System.currentTimeMillis() - start);
    xmlResultFormatter.endTestSuite(jUnitTest);
    consoleResultFormatter.endTestSuite(jUnitTest);
   
    // print success of failure
    if (result.wasSuccessful()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.