当前位置: 首页>>代码示例>>Java>>正文


Java TestResultMessage类代码示例

本文整理汇总了Java中org.testng.remote.strprotocol.TestResultMessage的典型用法代码示例。如果您正苦于以下问题:Java TestResultMessage类的具体用法?Java TestResultMessage怎么用?Java TestResultMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TestResultMessage类属于org.testng.remote.strprotocol包,在下文中一共展示了TestResultMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDuration

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
@Override
public Long getDuration() {
  TestResultMessage message = getResultMessage();
  if (message != null) {
    return (message.getEndMillis() - message.getStartMillis());
  }
  else {
    // TODO cache?
    long duration = 0;
    for (TestProxy testProxy : getChildren()) {
      final Long d = testProxy.getDuration();
      duration += (d == null ? 0 : d.longValue());
    }
    return duration;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:TestProxy.java

示例2: getPrintables

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
private static List<Printable> getPrintables(final TestResultMessage result) {
  String s = trimStackTrace(result.getStackTrace());
  List<Printable> printables = new ArrayList<Printable>();
  //figure out if we have a diff we need to hyperlink
  if (appendDiffChuncks(result, s, printables, COMPARISION_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_BUT_WAS_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_BUT_WAS_SET_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_NOT_SAME_BUT_WAS_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_BUT_FOUND_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_BUT_WAS_HAMCREST_PATTERN)) {
    return printables;
  }
  printables.add(new Chunk(s, ConsoleViewContentType.ERROR_OUTPUT));
  return printables;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:TestProxy.java

示例3: appendDiffChuncks

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
private static boolean appendDiffChuncks(final TestResultMessage result, String s, List<Printable> printables, final Pattern pattern) {
  final Matcher matcher = pattern.matcher(s);
  if (matcher.matches()) {
    printables.add(new Chunk(matcher.group(1), ConsoleViewContentType.ERROR_OUTPUT));
    //we have an assert with expected/actual, so we parse it out and create a diff hyperlink
    DiffHyperlink link = new DiffHyperlink(matcher.group(2), matcher.group(3), null) {
      protected String getTitle() {
        //TODO should do some more farting about to find the equality assertion that failed and show that as title
        return result.getTestClass() + '#' + result.getMethod() + "() failed";
      }
    };
    //same as junit diff view
    printables.add(link);
    printables.add(new Chunk(trimStackTrace(s.substring(matcher.end(3) + 1)), ConsoleViewContentType.ERROR_OUTPUT));
    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TestProxy.java

示例4: addTestResult

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public void addTestResult(TestResultMessage result) {
  if (testNGResults != null) {
    int exceptionMark = myExceptionalMark == -1 ? 0 : myExceptionalMark;

    if (currentTest != null) {
      final String stackTrace = result.getStackTrace();
      if (stackTrace != null && stackTrace.length() > 10) {
        exceptionMark = currentTest.getCurrentSize();
        //trim useless crud from stacktrace
        currentTest.appendStacktrace(result);
      }
      final TestProxy failedToStart = testNGResults.getFailedToStart();
      if (failedToStart != null) {
        currentTest.addChild(failedToStart);
      }
    }
    testNGResults.addTestResult(result, exceptionMark);
    myExceptionalMark = -1;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:TestNGConsoleView.java

示例5: getPackageClassNodeFor

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
private TestProxy getPackageClassNodeFor(final TestResultMessage result) {
  TestProxy owner = treeBuilder.getRoot();
  final String packageName1 = StringUtil.getPackageName(result.getTestClass());
  String packageName = packageName1.length() == 0 ? NO_PACKAGE : packageName1;
  owner = getChildNodeNamed(owner, packageName);
  if (owner.getPsiElement() == null) {
    owner.setPsiElement(JavaPsiFacade.getInstance(project).findPackage(packageName));
  }
  owner = getChildNodeNamed(owner, StringUtil.getShortName(result.getTestClass()));
  //look up the psiclass now
  if (owner.getPsiElement() == null) {
    final TestProxy finalOwner = owner;
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      public void run() {
        finalOwner.setPsiElement(ClassUtil.findPsiClass(PsiManager.getInstance(project), result.getTestClass()));
      }
    });
  }
  return owner;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:TestNGResults.java

示例6: isVersionIncompatible

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public static boolean isVersionIncompatible(Project project, GlobalSearchScope scope) {
  final String protocolClassMessageClass = TestResultMessage.class.getName();
  final PsiClass psiProtocolClass = JavaPsiFacade.getInstance(project).findClass(protocolClassMessageClass, scope);
  if (psiProtocolClass != null) {
    final String instanceFieldName = "m_instanceName";
    try {
      final boolean userHasNewJar = psiProtocolClass.findFieldByName(instanceFieldName, false) != null;

      boolean ideaHasNewJar = true;
      final Class aClass = Class.forName(protocolClassMessageClass);
      try {
        aClass.getDeclaredField(instanceFieldName);
      }
      catch (NoSuchFieldException e) {
        ideaHasNewJar = false;
      }

      return userHasNewJar != ideaHasNewJar;
    }
    catch (Exception ignore) {
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TestNGVersionChecker.java

示例7: getPrintables

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
private static List<Printable> getPrintables(final TestResultMessage result) {
  String s = trimStackTrace(result.getStackTrace());
  List<Printable> printables = new ArrayList<Printable>();
  //figure out if we have a diff we need to hyperlink
  if (appendDiffChuncks(result, s, printables, COMPARISION_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_BUT_WAS_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_BUT_WAS_SET_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_NOT_SAME_BUT_WAS_PATTERN)) {
    return printables;
  }
  if (appendDiffChuncks(result, s, printables, EXPECTED_BUT_FOUND_PATTERN)) {
    return printables;
  }
  printables.add(new Chunk(s, ConsoleViewContentType.ERROR_OUTPUT));
  return printables;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:TestProxy.java

示例8: valueOf

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public String valueOf(final TestResultMessage result) {
  switch (result.getResult()) {
    case MessageHelper.PASSED_TEST:
      return "Pass";
    case MessageHelper.FAILED_TEST:
      return "Fail";
    case MessageHelper.SKIPPED_TEST:
      return "Skipped";
    case MessageHelper.FAILED_ON_PERCENTAGE_TEST:
      return "Failed On %";
    default:
      return "Unknown result " + result.getResult();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:TestNGResultsTableModel.java

示例9: getComparator

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public Comparator<TestResultMessage> getComparator() {
  return new Comparator<TestResultMessage>() {
    public int compare(final TestResultMessage o1, final TestResultMessage o2) {
      return o1.getResult() - o2.getResult();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:TestNGResultsTableModel.java

示例10: setResultMessage

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public void setResultMessage(final TestResultMessage resultMessage) {
  //if we have a result, then our parent is a class, so we can look up our method
  //this is a bit fragile as it assumes parent is set first and correctly
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    public void run() {
      PsiClass psiClass = (PsiClass)getParent().getPsiElement();
      if (psiClass != null) {
        PsiMethod[] methods = psiClass.getAllMethods();
        for (PsiMethod method : methods) {
          if (method.getName().equals(resultMessage.getMethod())) {
            setPsiElement(method);
            break;
          }
        }
      }
    }
  });

  TestProxy current = this;
  while (current != null) {
    current.inProgress = resultMessage.getResult() == MessageHelper.TEST_STARTED;
    current = current.getParent();
  }
  if (this.resultMessage == null || this.resultMessage.getResult() == MessageHelper.TEST_STARTED) {
    this.resultMessage = resultMessage;
    final PsiElement psiElement = getPsiElement();
    this.name = toDisplayText(resultMessage, psiElement != null ? psiElement.getProject() : null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:TestProxy.java

示例11: toDisplayText

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public static String toDisplayText(TestResultMessage message, Project project) {
  String name = message.getName();
  if (project != null && Comparing.strEqual(name, project.getName())) {
    name = message.getMethod();
  }
  final String mainNamePart = name;
  final String[] parameters = message.getParameters();
  if (parameters != null && parameters.length > 0) {
    final String[] parameterTypes = message.getParameterTypes();
    name += " (";
    for(int i= 0; i < parameters.length; i++) {
      if(i > 0) {
        name += ", ";
      }
      if(CommonClassNames.JAVA_LANG_STRING.equals(parameterTypes[i]) && !("null".equals(parameters[i]) || "\"\"".equals(parameters[i]))) {
        name += "\"" + parameters[i] + "\"";
      }
      else {
        name += parameters[i];
      }

    }
    name += ")";
  }
  final String testDescription = message.getTestDescription();
  if (testDescription != null && !Comparing.strEqual(testDescription, mainNamePart)) {
    name += " [" + testDescription + "]";
  }
  return name;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:TestProxy.java

示例12: TestNGResults

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public TestNGResults(final JComponent component,
                     final TestNGConfiguration configuration,
                     final TestNGConsoleView console) {
  super(component, console.getConsole().createConsoleActions(), console.getProperties(),
        TESTNG_SPLITTER_PROPERTY, 0.5f);
  this.configuration = configuration;
  this.project = configuration.getProject();

  model = new TestNGResultsTableModel(project);
  resultsTable = new TableView(model);
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      final Object result = resultsTable.getSelectedObject();
      if (result instanceof TestResultMessage) {
        final String testClass = ((TestResultMessage)result).getTestClass();
        final PsiClass psiClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), testClass);
        if (psiClass != null) {
          final String method = ((TestResultMessage)result).getMethod();
          if (method != null) {
            final PsiMethod[] psiMethods = psiClass.findMethodsByName(method, false);
            if (psiMethods.length > 0) {
              psiMethods[0].navigate(true);
            }
          }
          psiClass.navigate(true);
          return true;
        }
      }
      return false;
    }
  }.installOn(resultsTable);

  rootNode = new TreeRootNode();
  console.getUnboundOutput().addChild(rootNode);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:TestNGResults.java

示例13: testStarted

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public TestProxy testStarted(TestResultMessage result, boolean registerDups) {
  TestProxy classNode = getPackageClassNodeFor(result);
  TestProxy proxy = new TestProxy();
  proxy.setParent(classNode);
  proxy.setResultMessage(result);
  synchronized (started) {
    if (registerDups) {
      List<TestProxy> dups = started.get(result);
      if (dups == null) {
        dups = new ArrayList<TestProxy>();
        started.put(result, dups);
      }
      dups.add(proxy);
    }
  }
  final String testMethodDescriptor = result.getTestClass() + TestProxy.toDisplayText(result, project);
  if (startedMethods.contains(testMethodDescriptor)) {
    total++;
  }
  else {
    startedMethods.add(testMethodDescriptor);
  }
  animator.setCurrentTestCase(proxy);
  treeBuilder.addItem(classNode, proxy);
  //treeBuilder.repaintWithParents(proxy);
  count++;
  if (count > total) total = count;
  if (myLastSelected == proxy) {
    myLastSelected = null;
  }
  if (myLastSelected == null && TestConsoleProperties.TRACK_RUNNING_TEST.value(myProperties)) {
    selectTest(proxy);
  }
  return proxy;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:TestNGResults.java

示例14: startElement

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
@Override
public void startElement (String uri, String localName,
    String qName, Attributes attributes) {
  p("Start " + qName);
  if (TAG_SUITE.equals(qName)) {
    m_suiteListener.onInitialization(new GenericMessage());
    m_suiteMethodCount = 0;
    m_currentSuite = new SuiteMessage(attributes.getValue(ATTR_NAME),
        true /* start */, m_suiteMethodCount);
    m_suiteListener.onStart(m_currentSuite);
  } else if (TAG_TEST.equals(qName)) {
    m_passed = m_failed = m_skipped = 0;
    m_currentTest = new TestMessage(true /* start */, m_currentSuite.getSuiteName(),
        attributes.getValue(ATTR_NAME), m_testMethodCount,
        m_passed, m_failed, m_skipped, 0);
    m_testListener.onStart(m_currentTest);
  } else if (TAG_CLASS.equals(qName)) {
    m_className = attributes.getValue(ATTR_NAME);
  } else if (TAG_TEST_METHOD.equals(qName)) {
    Integer status = XMLReporterConfig.getStatus(attributes.getValue(ATTR_STATUS));
    m_currentTestResult = new TestResultMessage(status, m_currentSuite.getSuiteName(),
        m_currentTest.getTestName(), m_className, attributes.getValue(ATTR_NAME),
        attributes.getValue(ATTR_DESC),
        attributes.getValue(ATTR_DESC),
        new String[0], /* no parameters, filled later */
        0, Long.parseLong(attributes.getValue(ATTR_DURATION_MS)),
        "" /* stack trace, filled later */,
        m_invocationCount, m_currentInvocationCount);
    m_suiteMethodCount++;
    m_testMethodCount++;
    if (status == ITestResult.SUCCESS) m_passed++;
    else if (status == ITestResult.FAILURE) m_failed++;
    else if (status == ITestResult.SKIP) m_skipped++;
  } else if (TAG_PARAMS.equals(qName)) {
    m_params = Lists.newArrayList();
  }
}
 
开发者ID:testng-team,项目名称:testng-remote,代码行数:38,代码来源:ResultContentHandler.java

示例15: TestNGResults

import org.testng.remote.strprotocol.TestResultMessage; //导入依赖的package包/类
public TestNGResults(final JComponent component,
                     final TestNGConfiguration configuration,
                     final TestNGConsoleView console,
                     final ExecutionEnvironment environment) {
  super(component, console.getConsole().createConsoleActions(), console.getProperties(),
        environment, TESTNG_SPLITTER_PROPERTY, 0.5f);
  this.project = configuration.getProject();

  model = new TestNGResultsTableModel(project);
  resultsTable = new TableView(model);
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      final Object result = resultsTable.getSelectedObject();
      if (result instanceof TestResultMessage) {
        final String testClass = ((TestResultMessage)result).getTestClass();
        final PsiClass psiClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), testClass);
        if (psiClass != null) {
          final String method = ((TestResultMessage)result).getMethod();
          if (method != null) {
            final PsiMethod[] psiMethods = psiClass.findMethodsByName(method, false);
            if (psiMethods.length > 0) {
              psiMethods[0].navigate(true);
            }
          }
          psiClass.navigate(true);
          return true;
        }
      }
      return false;
    }
  }.installOn(resultsTable);

  rootNode = new TreeRootNode();
  console.getUnboundOutput().addChild(rootNode);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:TestNGResults.java


注:本文中的org.testng.remote.strprotocol.TestResultMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。