使用gruntfile.js将mochawesome.json测试报告转换为Junit xml报告

时间:2019-01-09 12:05:52

标签: jenkins jenkins-plugins jenkins-pipeline jenkins-cli

我必须将mochatests生成的json格式的测试结果转换为Junit xml文件,以便使用测试结果分析器插件在jenkins上生成交互式测试报告。

我已经尝试使用npm提供的jsonjunit在package.json中添加了依赖项,并尝试了下面的代码。


mochaTest: {
  serviceTest: {
    options: {
      reporter: 'mochawesome',
      reporterOptions: {
        reportDir: '<%= dir.report %>',
        captureFile: '<%= dir.report %>/TEST-serviceTests.html', // Optionally capture the reporter output to a file
        reportName: 'customReportName'
      },
      Optionally capture the reporter output to a file
      quiet: false, // Optionally suppress output to standard out (defaults to false)
      timeout: 300000, // global timeout for all service tests
      clearRequireCache: false // Optionally clear the require cache before running tests (defaults to false)
    },
    src: ['dist/test/service/**/*.js'],
      command: [
         'node_modules/.bin/jsonjunit --json Reporter/src/report/mochawesome.json --junit Reporter/src/report/mochawesomejunit.xml'
      ].join('&')
  },

  dbTest: {
    options: {
      reporter: '<%= properties.mochaReporter %>',
      captureFile: '<%= dir.report %>/TEST-dbTests.xml', // Optionally capture the reporter output to a file
      quiet: false, // Optionally suppress output to standard out (defaults to false)
      timeout: 300000, // global timeout for all db tests
      clearRequireCache: false // Optionally clear the require cache before running tests (defaults to false)
    },
    src: ['dist/test/helper/db.test.js']
  }
}

0 个答案:

没有答案