function createRunReporterFunction(ctor) {
  /**
   * Run reporter using stream reassignment to capture output.
   *
   * @param {Object} stubSelf - Reporter-like stub instance
   * @param {Runner} runner - Mock instance
   * @param {Object} [options] - Reporter configuration settings
   * @param {boolean} [tee=false] - Whether to echo output to screen
   * @return {string[]} Lines of output written to `stdout`
   */
  var runReporter = function (stubSelf, runner, options, tee) {
    var origStdoutWrite = process.stdout.write;
    var stdoutWriteStub = sinon.stub(process.stdout, 'write');
    var stdout = [];

    var gather = function (chunk, enc, callback) {
      stdout.push(chunk);
      if (tee) {
        origStdoutWrite.call(process.stdout, chunk);
      }
    };

    // Reassign stream in order to make a copy of all reporter output
    stdoutWriteStub.callsFake(gather);

    // Give `stubSelf` access to `ctor` prototype chain
    Object.setPrototypeOf(stubSelf, ctor.prototype);

    try {
      // Invoke reporter
      ctor.call(stubSelf, runner, options);
    } finally {
      // Revert stream reassignment here so reporter output
      // can't be corrupted if any test assertions throw
      stdoutWriteStub.restore();
    }

    return stdout;
  };

  return runReporter;
}
Creates closure with reference to the reporter class constructor.

@param {Function} ctor - Reporter class constructor
@return {createRunReporterFunction~runReporter}