コード例 #1
0
  self.handleStepResultEvent = function handleStepResult(event, callback) {
    var stepResult = event.getPayloadItem('stepResult');

    var step = stepResult.getStep();
    self.formatStep(step);

    var stepOutput = {};
    var resultStatus = 'failed';

    if (stepResult.isSuccessful()) {
      resultStatus = 'passed';
    }
    else if (stepResult.isPending()) {
      resultStatus = 'pending';
      stepOutput['error_message'] = undefined;
    }
    else if (stepResult.isSkipped()) {
      resultStatus = 'skipped';
    }
    else if (stepResult.isUndefined()) {
      resultStatus = 'undefined';
    }
    else {
      var failureMessage = stepResult.getFailureException();
      if (failureMessage) {
        stepOutput['error_message'] = (failureMessage.stack || failureMessage);
      }
    }

    stepOutput['status'] = resultStatus;
    gherkinJsonFormatter.result(stepOutput);
    gherkinJsonFormatter.match({location: undefined});
    callback();
  }
コード例 #2
0
ファイル: json_formatter.js プロジェクト: Surekh/cucumber-js
  self.handleStepResultEvent = function handleStepResultEvent(event, callback) {
    var stepResult = event.getPayloadItem('stepResult');

    var step = stepResult.getStep();
    self.formatStep(step);

    var stepOutput = {};
    var resultStatus;
    var attachments;

    if (stepResult.isSuccessful()) {
      resultStatus = 'passed';
      if (stepResult.hasAttachments()) {
        attachments = stepResult.getAttachments();
      }
      stepOutput['duration'] = stepResult.getDuration();
    }
    else if (stepResult.isPending()) {
      resultStatus = 'pending';
      stepOutput['error_message'] = undefined;
    }
    else if (stepResult.isSkipped()) {
      resultStatus = 'skipped';
    }
    else if (stepResult.isUndefined()) {
      resultStatus = 'undefined';
    }
    else {
      resultStatus = 'failed';
      var failureMessage = stepResult.getFailureException();
      if (failureMessage) {
        stepOutput['error_message'] = (failureMessage.stack || failureMessage);
      }
      if (stepResult.hasAttachments()) {
        attachments = stepResult.getAttachments();
      }
      stepOutput['duration'] = stepResult.getDuration();
    }

    stepOutput['status'] = resultStatus;
    gherkinJsonFormatter.result(stepOutput);
    gherkinJsonFormatter.match({location: undefined});
    if (attachments) {
      attachments.syncForEach(function(attachment) {
        gherkinJsonFormatter.embedding(attachment.getMimeType(), attachment.getData());
      });
    }
    callback();
  }