Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why when test fails jenkins still says success?

I have a MEAN project. Using Jenkins on an EC2 machine I build this using the following shell script:

npm install && PORT=8888 npm test

mocha returns 2 (number of failing tests) but still jenkins says:

Finished: SUCCESS.

If tests are failing I expect to see

Finished: FAILURE

Do you know why its not working fine?

like image 415
Cristian Boariu Avatar asked Aug 09 '16 19:08

Cristian Boariu


Video Answer


2 Answers

You can:

  1. Use a test runner like Karma, or
  2. Tell Mocha to report in, for example, XUnit format, by passing Mocha the --reporter xunit flag. XUnit closely aligns with JUnit which Jenkins understands, or
  3. Add in a custom reporter — mocha-jenkins-reporter is a decent option.
like image 81
Chris Cashwell Avatar answered Oct 12 '22 09:10

Chris Cashwell


In the end I used a different solution: installed Jenkins Text Finder and if "expected - actual" is found in log (test failed), I let this plugin to mark the build as "Unstable".

like image 24
Cristian Boariu Avatar answered Oct 12 '22 10:10

Cristian Boariu