0
votes

We run unit and acceptance (e2e) tests on Jenkins using Karma and Grunt. Karma produces JUnit reports using the karma-junit-reporter, and we've configured Jenkins to set the build as unstable (yellow) if test failures are found in these report files.

The problem is that whenever a test fails, Karma and Grunt exits with a non-zero exit code and this makes the build failed (red). Can this behavior be altered?

I'd prefer not to run Grunt with --force, because I still want a failed build when the tests cannot be executed or when other tasks fail.

1

1 Answers

1
votes

This seems to be a common problem with many test runners. I myself execute my tests like this:

test-runner || true

This means the exit code of test-runner is ignored completely. If there is a problem with test-runner and it does not run at all, it probably does not produce test result xml files either, which will make the build fail because Jenkins wants to find at least one test result file.