When I create parameterized test cases in JUnit 3.x, I usually create TestSuite with something like
public static Test suite() { TestSuite s = new TestSuite(); for (int i = MIN; i < MAX; ++i) { s.addTest(new MyTest(i)); } }
This suite() method is called correctly when running JUnit from the desktop command line. When I tried this with my Android test project, the tests do not run. How to make my tests run on an emulator? Or is there another way to create parameterized tests for Android?
Other thoughts:
I usually run my tests using the command line:
adb shell am instrument -w [-e class <fully qualified test class name>[#<test method name>()]] <Android package name>/android.test.InstrumentationTestRunner
This allows me to choose which tests to run from my test suite. Ideally, I also want to run parameterized tests. The link in the comment from @Appu describes the creation of a separate application that runs JUnit tests. As part of this, this application has a custom TestRunner. I can probably borrow these ideas to create a TestRunner, which I can use instead of android.test.InstrumentationTestRunner . This seems like a lot of work for an extraordinary task. I prefer not to reinvent the wheel if the Android API already has a similar solution. Does anyone know about this? In addition, other alternative solutions will be helpful.
Nevermind, it looks like @dtmilano already posted this as an answer ...
source share