Trigger Jenkins build failure from Android Spoon

467 views Asked by At

I have a Jenkins job that runs Spoon to execute instrumentation tests. One of the tests fails but the this does not cause Jenkins to mark the build as a failure as I would expect.

How would I propagate the test failure to Jenkins?

Here's my build step to launch Spoon:

java -jar $SPOON_RUNNER_JAR_PATH \
  --sdk $ANDROID_SDK_DIR \
  --apk testPackages/$testedApkName \
  --test-apk testPackages/$testApkName
2

There are 2 answers

0
Peter Tran On

I noticed that Spoon outputs a file spoon-output/result.json that could be parsed for individual test failures. Each test has a JSON field that looks like

"status": "PASS"

So Log Parser Plugin could be used. A parsing rule would need to be created, something like:

error /"status": "FAIL".*/
0
CoatedMoose On

Spoon also stores the junit format test results in build/spoon/<build_flavour>/<build_type>/junit-reports/*.xml.

You can then use JUnit or xUnit to mark the build as failing according to your need. I prefer xUnit because it allows setting a threshold for allowed failures.