Package com.google.jstestdriver.idea.execution.tc

Examples of com.google.jstestdriver.idea.execution.tc.TCMessage


  }

  @NotNull
  @Override
  public TCMessage createStartedMessage() {
    TCMessage message = TC.newBrowserErrorStartedMessage(this);
    ConfigNode configNode = getParent().getParent();
    String basePath = configNode.getAbsoluteBasePath();
    if (basePath != null) {
      message.addAttribute(TCAttribute.NODE_TYPE, "browserError");
      message.addAttribute(TCAttribute.NODE_ARGS, basePath);
    }
    return message;
  }
View Full Code Here


  }

  @NotNull
  @Override
  public TCMessage createStartedMessage() {
    TCMessage message = super.createStartedMessage();
    String basePath = getParent().getAbsoluteBasePath();
    if (basePath != null) {
      message.addAttribute(TCAttribute.NODE_TYPE, "browser");
      message.addAttribute(TCAttribute.NODE_ARGS, basePath);
    }
    return message;
  }
View Full Code Here

  public void onTestCompleted(@NotNull TestPath testPath, @NotNull TestResult testResult) {
    TestNode testNode = getOrCreateTestNode(testPath);
    testNode.detachFromParent();
    String log = testResult.getLog();
    if (log != null && !log.isEmpty()) {
      TCMessage stdOutMessage = TC.newTestStdOutMessage(testNode);
      stdOutMessage.addAttribute(TCAttribute.STDOUT, log + "\n");
      printTCMessage(stdOutMessage);
    }

    int durationMillis = (int) testResult.getTime();
    TestResult.Result status = testResult.getResult();
    if (status == TestResult.Result.passed) {
      TCMessage testFinishedMessage = TC.newTestFinishedMessage(testNode);
      testFinishedMessage.addIntAttribute(TCAttribute.TEST_DURATION, durationMillis);
      printTCMessage(testFinishedMessage);
    } else {
      final String originalStack = testResult.getStack();
      final String parsedMessage = testResult.getParsedMessage();
      final String stackStr;
      if (originalStack.startsWith(parsedMessage)) {
        String s = originalStack.substring(parsedMessage.length());
        stackStr = s.replaceFirst("^[\n\r]*", "");
      } else {
        stackStr = originalStack;
      }
      TCMessage testFailedMessage = TC.newTestFailedMessage(testNode);
      testFailedMessage.addAttribute(TCAttribute.EXCEPTION_MESSAGE, parsedMessage);
      testFailedMessage.addAttribute(TCAttribute.EXCEPTION_STACKTRACE, stackStr);
      if (status == TestResult.Result.error) {
        testFailedMessage.addAttribute(TCAttribute.IS_TEST_ERROR, "yes");
      }
      testFailedMessage.addIntAttribute(TCAttribute.TEST_DURATION, durationMillis);
      printTCMessage(testFailedMessage);
    }
  }
View Full Code Here

        for (TestCaseNode testCaseNode : browserNode.getChildren()) {
          testCount += testCaseNode.getChildren().size();
        }
      }
      if (testCount > 0) {
        TCMessage tcMessage = new TCMessage(TCCommand.TEST_COUNT);
        tcMessage.addAttribute(TCAttribute.TEST_COUNT, String.valueOf(testCount));
        printTCMessage(tcMessage);
      }
    }
  }
View Full Code Here

  public void onJstdConfigRunningFinished(@Nullable String errorMessage, @NotNull TestFileScope testFileScope) {
    ConfigNode configNode = getCurrentConfigNode();
    for (BrowserNode browserNode : configNode.getChildren()) {
      for (TestCaseNode testCaseNode : browserNode.getChildren()) {
        for (TestNode testNode : testCaseNode.getChildren()) {
          TCMessage testFailedMessage = TC.newTestFailedMessage(testNode);
          String reason = errorMessage != null ? "JsTestDriver crash" : "unknown reason";
          testFailedMessage.addAttribute(TCAttribute.EXCEPTION_MESSAGE, "Can't execute test due to " + reason + ".");
          testFailedMessage.addAttribute(TCAttribute.IS_TEST_ERROR, "yes");
          printTCMessage(testFailedMessage);
        }
        TCMessage testCaseFinishedMessage = TC.newTestSuiteFinishedMessage(testCaseNode);
        printTCMessage(testCaseFinishedMessage);
      }
      TCMessage browserFinishedMessage = TC.newTestSuiteFinishedMessage(browserNode);
      printTCMessage(browserFinishedMessage);
    }
    if (errorMessage != null) {
      ConfigErrorNode configErrorNode = new ConfigErrorNode(configNode);
      TCMessage startedMessage = configErrorNode.createStartedMessage();
      printTCMessage(startedMessage);
      TCMessage finishedMessage = TC.newConfigErrorFinishedMessage(configErrorNode);
      finishedMessage.addAttribute(TCAttribute.EXCEPTION_MESSAGE, errorMessage);
      printTCMessage(finishedMessage);
    }
    else if (configNode.getChildren().isEmpty()) {
      final String message;
      Map.Entry<String, Set<String>> testCaseEntry = testFileScope.getSingleTestCaseEntry();
      if (testCaseEntry != null) {
        Set<String> testMethodNames = testCaseEntry.getValue();
        if (testMethodNames.isEmpty()) {
          message = "No '" + testCaseEntry.getKey() + "' test case found or it has no tests.";
        }
        else {
          message = "No '" + testFileScope.humanize() + "' test method found.";
        }
      }
      else {
        message = "No tests found. Please check 'test:' section of the configuration file.";
      }
      myErrStream.println(message);
    }
    TCMessage configFinishedMessage = TC.newTestSuiteFinishedMessage(configNode);
    printTCMessage(configFinishedMessage);
  }
View Full Code Here

    if (browserNode == null) {
      browserNode = new BrowserNode(browserName, configNode);
      configNode.addChild(browserNode);
    }
    BrowserErrorNode browserErrorNode = BrowserErrorNode.newBrowserErrorNode(browserNode, pathToJsFileWithError, errorMessage);
    TCMessage startedMessage = browserErrorNode.createStartedMessage();
    printTCMessage(startedMessage);

    TCMessage finishedMessage = TC.newBrowserErrorFinishedMessage(browserErrorNode);
    if (errorMessage != null) {
      finishedMessage.addAttribute(TCAttribute.EXCEPTION_MESSAGE, errorMessage);
    }
    printTCMessage(finishedMessage);
  }
View Full Code Here

    if (map == null) {
      map = Maps.newHashMap();
      myChildByName = map;
    }
    map.put(child.getName(), child);
    TCMessage startedMessage = child.createStartedMessage();
    myTreeManager.printTCMessage(startedMessage);
  }
View Full Code Here

TOP

Related Classes of com.google.jstestdriver.idea.execution.tc.TCMessage

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.