Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8220407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:30:27+00:00 2026-06-07T13:30:27+00:00

I am trying to create unit tests for a REST client that does some

  • 0

I am trying to create unit tests for a REST client that does some API calls. The client works fine in the live application, but I can’t get it to run in the test case.

Apparantly, LoaderTestCase.getLoaderResultSynchronously() could be used here (at least according to Android reference, but it will not accept my loader. The code:

public void testGetEventInfo() {
    // Init some vars
    ...

    // Create & execute loader
    RESTLoader loader = new RESTLoader(getContext(),
            RESTLoader.HTTPVerb.GET, action, params, LOADER_GET_NEWS);
    getLoaderResultSynchronously(loader);
}

This yields the error getLoaderResultSynchronously(Loader) in the type LoaderTestCase is not applicable for the arguments (RESTLoader).

RESTLoader extends AsyncLoader. Note that I’m using the supportlibrary, maybe the Loader in there is incompatible? The documentation gives no information on this.

I’ve tried to solve this in several ways, though none seem to work:

  • Registered a listener to loader. However, the callback never triggers
  • Using CountdownLatch (also with a listener). Again, no trigger/countdown timeout.
  • Playing around with the type template (), without success.
  • Similar solutions on SO, though again failing to reach the listener.

Does anybody know why getLoaderResultSynchronously will not accept the loader? Or another clean way of testing the Loader, including a way to test return data? I can test handling the return data in a separate case, but I would also like to test the actual data.

Sincerely,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:30:30+00:00Added an answer on June 7, 2026 at 1:30 pm

    Have you taken a look at the source code? You’ll find the following import statements:

    import android.content.Loader;
    import android.content.Loader.OnLoadCompleteListener;
    

    It doesn’t look like Android offers a support version for LoaderTestCase. The easiest solution would be to temporarily change to the non-support LoaderManager (that is, have your class make use of the android.content.Loader instead), test your app, and then switch back to the support implementation. You might also consider copying the testing source code into your project, import the support LoaderManager, and execute it directly. I’m not familiar with the test libraries for Loaders but it doesn’t seem outwardly obvious that this would cause any major issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write unit tests for an application that reports on Entries in
I'm trying to create some fixture data for my unit tests in CakePHP (via
I am trying to write some Unit Tests to test some custom NSOperations that
I'm trying to find a way to write some unit-tests that can be used
I'm trying to implement some unit tests for a couple of classes that rely
I am trying to create a unit test for a method that takes a
I am trying to run integration tests against a REST web service process that
I have a class that I am trying to do unit tests on. The
I'm trying to get into unit tests for a BizTalk application I'm working on,
I'm working on an ASP.NET MVC application, and am trying to write some unit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.