Take the 2-minute tour ×

Is it possible to run an Android JUnit test from within an android application? For example, i could make an Activity with a single button. When the button is clicked, the application runs a test that is packaged within it, and then prints the results of the test onto the screen. How would I go about doing something like this?

share|improve this question
Are you trying to duplicate the Android JUnit runner UI that is included in Eclipse? –  louielouie Oct 21 '12 at 23:22
Something like that, but instead of running it through Eclipse, run it from the app, and display the results in a similar fashion. –  user1763965 Oct 21 '12 at 23:25
add comment

1 Answer

The post http://dtmilano.blogspot.ca/2011/09/android-testing-running-tests-from-code.html explains exactly what you are trying to do.

The idea is to use startIntrumentation() from the Activity you want to use as launcher. To obtain the results you can read logcat. There is an example showing these two steps in the source code of my OSCON 2012 presentation available at github.

share|improve this answer
If you used something like this, how would you gather the test results? –  user1763965 Oct 22 '12 at 2:04
add comment

Your Answer


