public TRXParser()

in agent/src/jetbrains/buildServer/xmlReportPlugin/parsers/mstest/TRXParser.java [38:126]


  public TRXParser(@NotNull final TestReporter logger, @NotNull final String defaultSuiteName) {
    myLogger = logger;
    myDefaultSuiteName = defaultSuiteName;
    myNamesParser = new TestNamesTableParser(new TestNamesTableParser.Callback() {
      public void testMethodFound(@NotNull final String id, @NotNull final String testName) {
        myTestIdToName.put(id, testName);
      }
    });

    myResultsParser = new TestResultsTableParser(new TestResultsTableParser.Callback() {
      private TestName myTestName;

      private String testName() {
        return testName(myTestName);
      }

      private String testName(final TestName testName) {
        return testName.presentName(myTestIdToName.get(testName.getTestId()));
      }

      public void testFound(@NotNull final TestName testId) {
        if (myTestName != null) {
          LOG.warn("Test " + myTestName + " was not closed");
        }
        myTestName = testId;
        logger.openTest(testName());
        myReportedTestsCount++;
      }

      public void testOutput(@NotNull final TestName testId, @NotNull final String text) {
        if (myTestName == null || !myTestName.equals(testId)) {
          LOG.warn("Failed to log testOutput for not-opened test");
          return;
        }

        logger.testStdOutput(text);
      }

      public void testError(@NotNull final TestName testId, @NotNull final String text) {
        if (myTestName == null || !myTestName.equals(testId)) {
          LOG.warn("Failed to log testError for not-opened test");
          return;
        }
        logger.testErrOutput(text);
      }

      public void testException(@NotNull final TestName testId, @Nullable final String message, @Nullable final String error) {
        if (myTestName == null || !myTestName.equals(testId)) {
          LOG.warn("Failed to log testException for not-opened test");
          return;
        }
        logger.testFail(message, error);
      }

      public void testIgnored(@NotNull final TestName testId, @Nullable final String message, @Nullable final String error) {
        if (myTestName == null || !myTestName.equals(testId)) {
          LOG.warn("Failed to log testException for not-opened test");
          return;
        }
        final String toLog = (message == null ? "" : message) + (error == null ? "" : " " + error);
        logger.testIgnored(toLog);
      }

      public void warning(@Nullable final TestName testId, @NotNull final String message) {
        String name = "<NA>";
        if (testId != null) {
          name = testName(testId);
        }
        logger.warning("Test '" + name + "': " + message);
      }

      public void warning(@Nullable final String message, @Nullable final String exception) {
        logger.error("Runner error: " + message + "\r\n" + exception);
      }

      public void testFinished(@NotNull final TestName testId, @NotNull final TestOutcome outcome, final long duration) {
        if (myTestName == null) {
          LOG.warn("Test null was not opened");
        }
        logger.closeTest(duration);
        myTestName = null;
      }

      @Override
      public void error(@NotNull final String message) {
        myLogger.error(message);
      }
    });
  }