How to use junit-report-builder - 10 common examples

To help you get started, we’ve selected a few junit-report-builder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mucsi96 / nightwatch-cucumber / lib / cucumber-junit-report.js View on Github external
features.forEach(function (feature) {
    // create new feature
    const suite = builder
                    .testSuite()
                    .name(options.suiteNamePrefix + feature.name)

    // quit here if feature is empty
    if (!feature.elements) { return }
    // loop over scenarios
    feature.elements.forEach(function (scenario) {
      let result = false
      const messages = []
      // loop over steps
      scenario.steps.forEach(function (step) {
        // quit if steps are empty
        if (step.result) {
          // on failure
          if (step.result.status === 'failed') {
            result = 'failure'
github replicatedhq / replicated-lint / src / cmdutil / reporters.ts View on Github external
export function junitReporter(__: string, rulesUsed: linter.YAMLRule[], results: linter.RuleTrigger[], outputDir: string) {
  const reportBuilder = junitReports.newBuilder();
  const suite = reportBuilder.testSuite().name("replicated-lint");

  const invalidYAMLError = getInvalidYAMLError(results);

  for (const rule of rulesUsed) {
    const testCase = suite.testCase().className("replicated-lint").name(rule.name);

    if (invalidYAMLError) { // if the yaml was invalid, then all the rules should fail regardless of results
      testCase.failure(invalidYAMLError.message);
      continue;
    }

    const result = _.find(results, r => r.rule === rule.name);
    if (result) {
      testCase.failure(result.message);
    }
github webdriverio-boneyard / wdio-junit-reporter / lib / reporter.js View on Github external
prepareXml (runners) {
        const builder = junit.newBuilder()
        for (const key of Object.keys(runners)) {
            const capabilities = runners[key]
            const packageName = this.options.packageName
                ? `${capabilities.sanitizedCapabilities}-${this.options.packageName}`
                : capabilities.sanitizedCapabilities

            for (let specId of Object.keys(capabilities.specs)) {
                const spec = capabilities.specs[specId]

                for (let suiteKey of Object.keys(spec.suites)) {
                    /**
                     * ignore root before all
                     */
                    /* istanbul ignore if  */
                    if (suiteKey.match(/^"before all"/)) {
                        continue
github mucsi96 / nightwatch-cucumber / lib / cucumber-junit-report.js View on Github external
break
        // if at least one step failed
        case 'failure':
          // mark as failure and output failure messages
          testCase
            .failure(messages.join('\n\n'))
          break
        // if a scenario runs without any failed or skipped steps
        default:
          // successful tests are already handled
      }
    })
  })

  // persistent data
  builder.writeTo(options.output)
}
github oxygenhq / oxygen / lib / reporters / junit-reporter.js View on Github external
JUnitXmlReporter.prototype.generate = function() {
    var resultFilePath = this.createFolderStructureAndFilePath('.xml');
    var resultFolderPath = path.dirname(resultFilePath);

    this.replaceScreenshotsWithFiles(resultFolderPath);
    // the 'results' object can contain a single test suite result or an array of multiple parallel test results
    if (this.results instanceof Array) {
        // go through multiple results
        _.each(this.results, function(resultSet) {
            populateSuiteResults(resultSet, builder);
        });
    } else {
        populateSuiteResults(this.results, builder);
    }

    builder.writeTo(resultFilePath);

    return resultFilePath;
};
github okta / okta-signin-widget / test / e2e / util / junit-reporter.js View on Github external
module.exports = function (result, outFile) {
  var suite = junitReportBuilder.testSuite()
    .name(result.url)
    .timestamp(new Date().getTime())
    .time(new Date().toGMTString());

  var packageName = result.url;

  result.violations.forEach(function (ruleResult) {

    ruleResult.nodes.forEach(function (violation) {
      var failure = ruleResult.help + ' (' + ruleResult.helpUrl + ')\n';
      var stacktrace = 'Target: ' + violation.target + '\n\n' +
        'HTML: ' + violation.html + '\n\n' +
        'Summary:\n';

      if (violation.any.length) {
        stacktrace += 'Fix any of the following:\n';
github bbc / a11y-tests-web / test / lib / lighthouse.js View on Github external
return lighthouseRunner.run().then(() => {
          sandbox.assert.calledWith(
            reportBuilder.testSuite().testCase().failure,
            'Error on http://www.bbc.co.uk/path/2\n' +
            'Image alt help text\n\n' +
            'Failing elements:\n' +
            'button &gt; svg[role="img"] - <svg class="cta__icon cta__icon--left" role="img">'
          );
        });
      });</svg>
github bbc / a11y-tests-web / test / lib / lighthouse.js View on Github external
return lighthouseRunner.run().then(() => {
          sandbox.assert.calledTwice(reportBuilder.testSuite);
          sandbox.assert.calledWith(reportBuilder.testSuite().name, 'base.url./path/1');
          sandbox.assert.calledWith(reportBuilder.testSuite().name, 'base.url./path/2');
        });
      });
github bbc / a11y-tests-web / test / lib / lighthouse.js View on Github external
return lighthouseRunner.run().then(() => {
          sandbox.assert.calledTwice(reportBuilder.testSuite);
          sandbox.assert.calledWith(reportBuilder.testSuite().time, 6000);
        });
      });
github bbc / a11y-tests-web / lib / lighthouse.js View on Github external
.then((results) => {
      const suiteName = url.replace(/.*?:\/\//g, '').replace('\/', './');
      const suite = reportBuilder.testSuite();
      suite.name(suiteName);

      const { audits, timing: { total: suiteDuration } } = results;

      suite.time(suiteDuration);

      const auditKeys = Object.keys(audits).filter((auditKey) => !audits[auditKey].manual);
      const testCaseTime = (suiteDuration / auditKeys.length);

      auditKeys.forEach((auditKey) => {
        const { score, manual, description, helpText, details = {}, extendedInfo = {} } = audits[auditKey];
        const testCase = suite.testCase();
        testCase.className(suiteName);
        testCase.name(description);
        testCase.time(testCaseTime);

junit-report-builder

Aimed at making it easier to build Jenkins compatible JUnit XML reports in plugins for testing frameworks

MIT
Latest version published 2 months ago

Package Health Score

74 / 100
Full package analysis