Your question is vague, to me. If you're asking how to run Android unit tests (classes in android.test.*) using MonkeyRunner:
Set up your Android tests, then call them from MonkeyRunner. You can, for example, write a single Python program using the MonkeyRunner API that goes through a set of emulators, each with its own configuration, runs a suite of test cases against each emulator, and then outputs the results to a file. You can do this because Python allows you to call the "emulator" comand-line program programmatically (see the "os" module). You use the device.instrument() method to call an instrumentation for a device, and instrumentation is the way you run an Android test. If you're asking how to run a Python unit test using MonkeyRunner, then it depends on what you're trying to do, but in general, you don't need to. If you want to use MonkeyRunner to run JUnit, I would ask "why"? You can run JUnit from the command line. Just because you can run JUnit (or an Android JUnit test) from Eclipse doesn't mean that you *have* to. The SDK documentation explains this. Look in the Dev Guide under "Developing > Testing > Testing with Other IDEs". JUnit runs each test method in each test class in a package of test classes. Similarly, the Android test framework uses instrumentation plus JUnit to run each test method in each test class in a test package. Some more comments about unit testing: Remember, *unit testing should focus on each test taking a single path through a single app method.* Use unit testing to verify that the class you've written works according to its specifications. Also use unit testing to verify that the latest change you made hasn't broken anything. Test-driven development says that your class and methods do what the *tests* say they do, not what the *code* says they do. What isn't tested not only doesn't work, it doesn't exist. In Android, you would do *true* unit testing by doing most of your functionality in Plain Old Java Objects (POJOs) and then testing these using JUnit. You would follow this by doing what I like to call "pseudo-unit" testing with Android's testing framework, using the test case classes in android.test.* and InstrumentationTestRunner. This framework allows you to test objects that require the Android environment. The documentation for some of them says that they are "unit tests", while others are documented as "functional tests". By the most strict definition they're all functional tests, but the nature of Android means that you can't do a "true" unit test on an object that depends on Android system objects. The reason: you can't create the Android system objects outside of Android, so you have to instantiate the object under test within Android, so you have to do a bit of hand-waving on the dependencies. Nonetheless, Android tests are more unit test than functional test. You *can't* do high-level functional testing or integration testing in the Android framework, because you can't test more than one Android object at a time. One of them has to be an external dependency that you must assume is working. You may decide that a useful way to do functional/integration testing is to use the Android test framework along with some larger framework. You write some tests using Android's test case classes. You then run multiple test cases sequentially to simulate UI interactions, processing, etc. You can use MonkeyRunner to do this. Perhaps a better way to do it is to use Robotium or Selenium. On Dec 17, 12:50 am, Miguel Pellón <[email protected]> wrote: > I would like to use some unit testing for python combined with the > monkeyrunner, but I have seen monkeyrunner is called via command line, > so I dont see the way of integrating it into a unit testing framework > (similar to junit). Any idea on how to do it? > > Thanks! > > Regards, > Miguel -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

