Publish Karma Unit Tests in Jenkins

Jenkins is already building my Maven Java project. I want the karma test results to be displayed in Jenkins, but unfortunately I am unable to make any configuration changes in Jenkins. How should karma be configured to fulfill it?

+3


source to share


3 answers


  • in order for Jenkins to parse karma test results, they must be published in Junit XML format, plugin that does this karma-junit-reporter
  • Junit test results ( outputFile

    in karma config file) should be stored intarget/surefire-reports/TESTS-TestSuite.xml



+5


source


    reporters        : ['progress', 'junit', 'coverage'],
    port             : 9876,
    colors           : true,
    logLevel         : config.LOG_INFO,
    // don't watch for file change
    autoWatch        : false,
    // only runs on headless browser
    browsers         : ['PhantomJS'],
    // just run one time
    singleRun        : true,
    // remove `karma-chrome-launcher` because we will be running on headless
    // browser on Jenkins
    plugins          : [
        'karma-jasmine',
        'karma-phantomjs-launcher',
        'karma-junit-reporter',
        'karma-coverage',
        'karma-jenkins-reporter'
    ],
    // changes type to `cobertura`
    coverageReporter : {
        type : 'cobertura',
        dir  : 'target/coverage-reports/'
    },
    // saves report at `target/surefire-reports/TEST-*.xml` because Jenkins
    // looks for this location and file prefix by default.
    junitReporter    : {
        outputDir : 'target/surefire-reports/'
    }

      



+1


source


Old post but better result on google.

  • Configure karma.conf.js to use 'karma-junit-reporter' and report to outputDir = 'target / karma-reports /'
  • In your pom.xml, include a test run step to execute / ID, like "karmaTests"
  • In your pom.xml set property jenkins.karmaTest.reportsDirectory = target / karma-reports

See this blog post for full examples .

0


source







All Articles