Question

I have an Android project which I build in Jenkins. I have set up a JUnit test-project for unit testing the app. This is very well integrated in Jenkins. All tests are run by an Ant build file and the test results can be displayed in Jenkins through plugins.

Now I wrote some functional tests for Monkeyrunner and want to integrate them in the Jenkins build, too.

What ways are there to do this? Of course, I can call Monkeyrunner as a shellscript-buildstep.

From what I understand, in a Monkeyrunner script I can only do something like:

test some stuff...
if xyz:
  print 'test successful'
else:
  print 'test failed'

But, since there is no Monkeyrunner plugin for Jenkins, how does Jenkins know the test result? Do I have to read out the console somehow, or what should I do?

I hope you guys can understand the question, my English is not that good.

Thank you in advance!

Was it helpful?

Solution

The Execute shell task will mark a build successful if your script exits with an exit status of 0. All other exit statuses will mark the build as failed. Within your monkeyrunner script, you can use the exit() statement to set your exit status.

# test some stuff...
if xyz:
  sys.exit(0) # success
else:
  sys.exit(1) # failure

If you need something more granular, you can use something like the Text-finder Plugin to parse the output of your Monkeyrunner scripts if using the exit code is insufficient.

edit: to clarify, add an Execute shell step, and invoke your monkeyrunner script from within that step. If the script exits with a status of 0, Jenkins will continue, otherwise it will fail the build.

You may need to provide the full path of the monkeyrunner interpereter, i.e:

/path/to/android-sdk/tools/monkeyrunner my-script.mr

OTHER TIPS

Despite it's name, you can use the Android Emulator Plugin to execute Monkey stress tests on your real device.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top