Package org.testng

Examples of org.testng.ITestNGMethod


    public void skipTestFiredEventsOrder() {
        ITestResult testResult = mock(ITestResult.class);
        when(testResult.getTestContext()).thenReturn(testContext);
        when(testResult.getThrowable()).thenReturn(new NullPointerException());
        when(testResult.getName()).thenReturn(DEFAULT_TEST_NAME);
        ITestNGMethod method = mock(ITestNGMethod.class);
        when(method.getDescription()).thenReturn(null);
        when(testResult.getMethod()).thenReturn(method);
       
        doReturn(new Annotation[0]).when(testngListener).getMethodAnnotations(testResult);

        testngListener.onTestSkipped(testResult);
View Full Code Here


        String stringParameter = "string";
        ITestResult testResult = mock(ITestResult.class);
        when(testResult.getTestContext()).thenReturn(testContext);
        when(testResult.getName()).thenReturn(DEFAULT_TEST_NAME);
        when(testResult.getParameters()).thenReturn(new Object[] { doubleParameter, stringParameter});
        ITestNGMethod method = mock(ITestNGMethod.class);
        when(method.getDescription()).thenReturn(null);
        when(testResult.getMethod()).thenReturn(method);
       
        doReturn(new Annotation[0]).when(testngListener).getMethodAnnotations(testResult);

        testngListener.onTestStart(testResult);
View Full Code Here

    @Override
    public List<IMethodInstance> intercept(List<IMethodInstance> methods,
            ITestContext context) {
        for (IMethodInstance methodIns : methods) {
            ITestNGMethod method = methodIns.getMethod();
            ConstructorOrMethod meth = method.getConstructorOrMethod();
            Method m = meth.getMethod();
            if (m != null) {
                DB db = m.getAnnotation(DB.class);
                if (db != null) {
                    Transaction txn = Transaction.open(m.getName());
View Full Code Here

public class IMethodInstanceComparator implements Comparator<IMethodInstance> {

    @Override
    public int compare(IMethodInstance left, IMethodInstance right) {
        ITestNGMethod m1 = left.getMethod();
        ITestNGMethod m2 = right.getMethod();
        int result = m1.getRealClass().getName().compareTo(m2.getRealClass().getName());
        if (result == 0) {
            result = m1.getMethodName().compareTo(m2.getMethodName());
        }
        return result;
    }
View Full Code Here

        boolean mangleMethodNames = manager.getNumConfigurations() > 1;
        TestDirectory testDirectory = TestDirectory.getInstance();
        List<IMethodInstance> newInstances = new ArrayList<IMethodInstance>();
        Set<TestAddress> targets = stagedReactor.getTargets();
        for (TestAddress address : targets) {
            ITestNGMethod frameworkMethod = (ITestNGMethod) manager
                .lookupTestMethod(address.root());
            if (frameworkMethod == null) {
                continue;
            }
            Method javaMethod = frameworkMethod.getConstructorOrMethod().getMethod();

            if (mangleMethodNames) {
                frameworkMethod = new ReactorTestNGMethod(frameworkMethod, javaMethod, address);
            }

            MethodInstance newInstance = new MethodInstance(frameworkMethod);
            newInstances.add(newInstance);
            methodToAddressMap.put(frameworkMethod.getMethodName(), address);
            testDirectory.add(address, new TestInstantiationInstruction(frameworkMethod
                .getRealClass().getName() + ";" + javaMethod.getName()));

        }
        Collections.sort(newInstances, new IMethodInstanceComparator());
        return newInstances;
View Full Code Here

          failedTests, skippedTests
      };

      for (Collection<ITestResult> tests : allTests) {
        for (ITestResult failedTest : tests) {
          ITestNGMethod current = failedTest.getMethod();
          if (current.isTest()) {
            methodsToReRun.add(current);
            ITestNGMethod method = failedTest.getMethod();
            // Don't count configuration methods
            if (method.isTest()) {
              List<ITestNGMethod> methodsDependedUpon =
                  MethodHelper.getMethodsDependedUpon(method, context.getAllTestMethods());
             
              for (ITestNGMethod m : methodsDependedUpon) {
                if (m.isTest()) {
View Full Code Here

   
    for (ITestResult tr : tests) {
      sb.append("<tr>\n");

      // Test method
      ITestNGMethod method = tr.getMethod();

      sb.append("<td title='").append(tr.getTestClass().getName()).append(".")
        .append(tr.getName())
        .append("()'>")
        .append("<b>").append(tr.getName()).append("</b>");
     
      // Test class
      String testClass = tr.getTestClass().getName();
      if (testClass != null) {
        sb.append("<br>").append("Test class: " + testClass);
       
        // Test name
        String testName = tr.getTestName();
        if (testName != null) {
          sb.append(" (").append(testName).append(")");
        }
      }
     
      // Method description
      if (! Utils.isStringEmpty(method.getDescription())) {
        sb.append("<br>").append("Test method: ").append(method.getDescription());
      }
     
      Object[] parameters = tr.getParameters();
      if (parameters != null && parameters.length > 0) {
        sb.append("<br>Parameters: ");
View Full Code Here

 
  }
 
  private static class ConfigurationComparator implements Comparator<ITestResult> {
    public int compare(ITestResult o1, ITestResult o2) {
      ITestNGMethod tm1= o1.getMethod();
      ITestNGMethod tm2= o2.getMethod();
      return annotationValue(tm2) - annotationValue(tm1);
    }
View Full Code Here

   
    SimpleDateFormat format = new SimpleDateFormat("yy/MM/dd HH:mm:ss");
    StringBuffer table = new StringBuffer();
    boolean addedHeader = false;
    for (IInvokedMethod iim : invokedMethods) {
      ITestNGMethod tm = iim.getTestMethod();
      table.setLength(0);
      if (!addedHeader) {
        table.append("<table border=\"1\">\n")
          .append("<tr>")
          .append("<th>Time</th>")
          .append("<th>Delta (ms)</th>")
          .append("<th>Suite<br>configuration</th>")
          .append("<th>Test<br>configuration</th>")
          .append("<th>Class<br>configuration</th>")
          .append("<th>Groups<br>configuration</th>")
          .append("<th>Method<br>configuration</th>")
          .append("<th>Test<br>method</th>")
          .append("<th>Thread</th>")
          .append("<th>Instances</th>")
          .append("</tr>\n");
        addedHeader = true;
      }
      String methodName = tm.toString();
      boolean bc = tm.isBeforeClassConfiguration();
      boolean ac = tm.isAfterClassConfiguration();
      boolean bt = tm.isBeforeTestConfiguration();
      boolean at = tm.isAfterTestConfiguration();
      boolean bs = tm.isBeforeSuiteConfiguration();
      boolean as = tm.isAfterSuiteConfiguration();
      boolean bg = tm.isBeforeGroupsConfiguration();
      boolean ag = tm.isAfterGroupsConfiguration();
      boolean setUp = tm.isBeforeMethodConfiguration();
      boolean tearDown = tm.isAfterMethodConfiguration();
      boolean isClassConfiguration = bc || ac;
      boolean isGroupsConfiguration = bg || ag;
      boolean isTestConfiguration = bt || at;
      boolean isSuiteConfiguration = bs || as;
      boolean isSetupOrTearDown = setUp || tearDown;
      String configurationClassMethod = isClassConfiguration ? (bc ? BEFORE : AFTER) + methodName : SP;
      String configurationTestMethod = isTestConfiguration ? (bt ? BEFORE : AFTER) + methodName : SP;
      String configurationGroupsMethod = isGroupsConfiguration ? (bg ? BEFORE : AFTER) + methodName : SP;
      String configurationSuiteMethod = isSuiteConfiguration ? (bs ? BEFORE : AFTER) + methodName : SP;
      String setUpOrTearDownMethod = isSetupOrTearDown ? (setUp ? BEFORE : AFTER) + methodName : SP;
      String testMethod = tm.isTest() ? methodName : SP;
     
      StringBuffer instances = new StringBuffer();
      for (long o : tm.getInstanceHashCodes()) {
        instances.append(o).append(" ");
      }
     
      if (startDate == -1) startDate = iim.getDate();
      String date = format.format(iim.getDate());
      table.append("<tr bgcolor=\"" + createColor(tm) + "\">")
        .append("  <td>").append(date).append("</td> ")
        .append("  <td>").append(iim.getDate() - startDate).append("</td> ")
        .append(td(configurationSuiteMethod))
        .append(td(configurationTestMethod))
        .append(td(configurationClassMethod))
        .append(td(configurationGroupsMethod))
        .append(td(setUpOrTearDownMethod))
        .append(td(testMethod))
        .append("  <td>").append(tm.getId()).append("</td> ")
        .append("  <td>").append(instances).append("</td> ")
        .append("</tr>\n")
        ;
      Utils.appendToFile(getOutputDirectory(xmlSuite), outputFileName, table.toString());
    }
View Full Code Here

                                      boolean isAfterTestMethod,
                                      String[] beforeGroups,
                                      String[] afterGroups)
  {
    if(method.getDeclaringClass().isAssignableFrom(clazz)) {
      ITestNGMethod confMethod = new ConfigurationMethod(method,
                                                         m_annotationFinder,
                                                         isBeforeSuite,
                                                         isAfterSuite,
                                                         isBeforeTest,
                                                         isAfterTest,
View Full Code Here

TOP

Related Classes of org.testng.ITestNGMethod

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.