Recently Android Support Library has been updated to v21.1.1. There were some changes and you can see the changed via the link:
https://developer.android.com/tools/support-library/index.html#revisions
One thing I have notice is new AppCompt* classes for appcompat library. Now you need to use AppCompatActivity instead of ActionBarActivity. It supports support library action bar features. ActionBarActivity now has been deprecated. I think this kind of too often changes in framework makes us developers annoying. Some people might just start to use ActionBarActivity.
In Android, test is not as easy as any other platform. Because Android test cannot be run without emulator. Particulary when it comes to AsyncTask or Service, it is difficult to test because they are different type of thread and hard to check their result. Then, how can we ensure the result of AsyncTask valid? AsyncTask is a thread and an asynchnorous as the name means. So, we need to wait for it finishes its job and need to capture the event. Then, when it happens in AsyncTask. It can be one of onBackground() and onPostExecute() methods. It doesn't matter you use onBackground() or onPostExecute() but I prefer onPostExecute(). Anyway, we can test an AsyncTask if we can hook it. Then, how can we hook it? For that, we can use callback pattern. But we need to delay main thread to wait for the AsyncTask's job done because we want to check the result. So the structure for the test would be like: 1. Create AsyncTask A 2. Injection a callback into A 3. Wait until A finish 4....
Comments
Post a Comment