I want to make a suite to test my webservice calls in an Android app. They extend AsynchTask.
I don't want to change my api to offer synchronous calls.
I tried already with JUnit / Android test project. The methods are run through but the callbacks never executed.
In order to use the test project setup, which at least manages to add the dependencies of the original project well, I made hacks. Kept using TestCase subclass but instead of using test methods, I called manually custom test methods from within setUp() method and instead of using JUnit's asserts I outout debug messages to the Log. I even added a test Method which calls a Thread.sleep(10000), for the case the callbacks are not executed because the class finishes to fast. Guess what, also didn't work. The callbacks are still never executed. I get Log messages before, but the log messages in the callbacks never appear.
I also tried a plain Java project. But this also didn't work, because of the AsynchTask and some other Android classes. Adding Android as a library to the Java project didn't work because the Android library is "stubbed" and only supposed to be used inside an Android project, as far I read researching.
So what do I do to test these webservices? I could test the webservices alone with plain Java project. But I would like to test my wrapper classes, which build the parameters and so on. But these wrapper classes are coupled with android library and AsynchTask and there's no way to change that.