lib/normalize.js
function(results, run, options, done) {

    _.each(results, function(result) {

      var pkg = {
        name: result.testsuites.$.name,
        tests: parse(result.testsuites.$.tests),
        failures: parse(result.testsuites.$.failures),
        suites: []
      };
      pkg.isFailure = pkg.failures > 0;

      var filename = result.filename;
      _.each(result.testsuites.testsuite, function(suiteData) {
        var $ = suiteData.$;

        var suite = {
          name: $.name,
          pkgName: $.package,
          failures: parse($.failures),
          errors: parse($.errors),
          skipped: parse($.skipped),
          tests: parse($.tests),
          cases: []
        };

        // Sometimes the package name isn't in the
        // xml reports...
        if (!pkg.name) {
          if (result.testsuites.filename) {
            pkg.name = result.testsuites.filename;
          } else {
            pkg.name = suite.pkgName;
          }
        } else {
          if (result.testsuites.filename) {
            pkg.name = result.testsuites.filename + '-' + pkg.name;
          }
        }

        suite.passed = suite.tests - suite.errors - suite.failures;
        suite.isFailure = suite.errors > 0 || suite.failures > 0;
        suite.errmessages = $['system-err'];
        pkg.suites.push(suite);

        _.each(suiteData.testcase, function(caseData) {

          var assert = {
            message: caseData.$.name,
            time: caseData.$.time,
            stacktrace: '',
            failure: false,
            skipped: false,
            screenshots: []

            // failure: false or failure message,
            // screenshots: ['path/to/screen1', '/path/to/screen2']
          };

          if (caseData.skipped)
            assert.skipped = true;

          if (caseData.failure && caseData.failure.length > 0)
            assert.failure = caseData.failure[0].$.message;

          if (caseData['system-out']) {
            var sspaths = getScreenshotPaths(caseData['system-out']);

            sspaths.map(function(sspath) {
              if (options.relativeScreenshots) {
                sspath = getRelativePath(options.fullOutputFilename, sspath);
              }
              assert.screenshots.push(sspath);
            });
          }

          assert.isFailure = assert.failure;
          suite.cases.push(assert);

          if (assert.isFailure)
            suite.isFailure = true;

        });

        if (suite.isFailure)
          pkg.isFailure = true;

      });

      run.addPackage(pkg);

    });

    done(null, run);
  }
function(results, run, options, done) {

    _.each(results, function(result) {

      var pkg = {
        name: result.testsuites.$.name,
        tests: parse(result.testsuites.$.tests),
        failures: parse(result.testsuites.$.failures),
        suites: []
      };
      pkg.isFailure = pkg.failures > 0;

      var filename = result.filename;
      _.each(result.testsuites.testsuite, function(suiteData) {
        var $ = suiteData.$;

        var suite = {
          name: $.name,
          pkgName: $.package,
          failures: parse($.failures),
          errors: parse($.errors),
          skipped: parse($.skipped),
          tests: parse($.tests),
          cases: []
        };

        // Sometimes the package name isn't in the
        // xml reports...
        if (!pkg.name) {
          if (result.testsuites.filename) {
            pkg.name = result.testsuites.filename;
          } else {
            pkg.name = suite.pkgName;
          }
        } else {
          if (result.testsuites.filename) {
            pkg.name = result.testsuites.filename + '-' + pkg.name;
          }
        }

        suite.passed = suite.tests - suite.errors - suite.failures;
        suite.isFailure = suite.errors > 0 || suite.failures > 0;
        suite.errmessages = $['system-err'];
        pkg.suites.push(suite);

        _.each(suiteData.testcase, function(caseData) {

          var assert = {
            message: caseData.$.name,
            time: caseData.$.time,
            stacktrace: '',
            failure: false,
            skipped: false,
            screenshots: []

            // failure: false or failure message,
            // screenshots: ['path/to/screen1', '/path/to/screen2']
          };

          if (caseData.skipped)
            assert.skipped = true;

          if (caseData.failure && caseData.failure.length > 0)
            assert.failure = caseData.failure[0].$.message;

          if (caseData['system-out']) {
            var sspaths = getScreenshotPaths(caseData['system-out']);

            sspaths.map(function(sspath) {
              if (options.relativeScreenshots) {
                sspath = getRelativePath(options.fullOutputFilename, sspath);
              }
              assert.screenshots.push(sspath);
            });
          }

          assert.isFailure = assert.failure;
          suite.cases.push(assert);

          if (assert.isFailure)
            suite.isFailure = true;

        });

        if (suite.isFailure)
          pkg.isFailure = true;

      });

      run.addPackage(pkg);

    });

    done(null, run);
  }
function ( results , run , options , done ) { _ . each ( results , function ( result ) { var pkg = { name : result . testsuites . $ . name , tests : parse ( result . testsuites . $ . tests ) , failures : parse ( result . testsuites . $ . failures ) , suites : [ ] } ; pkg . isFailure = pkg . failures > 0 ; var filename = result . filename ; _ . each ( result . testsuites . testsuite , function ( suiteData ) { var $ = suiteData . $ ; var suite = { name : $ . name , pkgName : $ . package , failures : parse ( $ . failures ) , errors : parse ( $ . errors ) , skipped : parse ( $ . skipped ) , tests : parse ( $ . tests ) , cases : [ ] } ; // Sometimes the package name isn't in the // xml reports... if ( ! pkg . name ) { if ( result . testsuites . filename ) { pkg . name = result . testsuites . filename ; } else { pkg . name = suite . pkgName ; } } else { if ( result . testsuites . filename ) { pkg . name = result . testsuites . filename + '-' + pkg . name ; } } suite . passed = suite . tests - suite . errors - suite . failures ; suite . isFailure = suite . errors > 0 || suite . failures > 0 ; suite . errmessages = $ [ 'system-err' ] ; pkg . suites . push ( suite ) ; _ . each ( suiteData . testcase , function ( caseData ) { var assert = { message : caseData . $ . name , time : caseData . $ . time , stacktrace : '' , failure : false , skipped : false , screenshots : [ ] // failure: false or failure message, // screenshots: ['path/to/screen1', '/path/to/screen2'] } ; if ( caseData . skipped ) assert . skipped = true ; if ( caseData . failure && caseData . failure . length > 0 ) assert . failure = caseData . failure [ 0 ] . $ . message ; if ( caseData [ 'system-out' ] ) { var sspaths = getScreenshotPaths ( caseData [ 'system-out' ] ) ; sspaths . map ( function ( sspath ) { if ( options . relativeScreenshots ) { sspath = getRelativePath ( options . fullOutputFilename , sspath ) ; } assert . screenshots . push ( sspath ) ; } ) ; } assert . isFailure = assert . failure ; suite . cases . push ( assert ) ; if ( assert . isFailure ) suite . isFailure = true ; } ) ; if ( suite . isFailure ) pkg . isFailure = true ; } ) ; run . addPackage ( pkg ) ; } ) ; done ( null , run ) ; }
Converts a object parsed from XML report files into models.
Converts a object parsed from XML report files into models .