Dejwi
Dejwi

Reputation: 4487

Android unittests how to create a ContentResolver stub?

I've got a following class in my project:

public class SmsManager {
  static final Uri message = Uri.parse("content://sms/");
  ContentResolver resolver;

  public SmsManager(ContentResolver resolver) {
    this.resolver = resolver;
  }

  ...

}

Class will be responsible for operations on sms messages (as Uri message suggested). How can I write unittests for it? How can I easily stub ContentResolver?

Upvotes: 0

Views: 134

Answers (1)

Magnus
Magnus

Reputation: 1502

Check out MockContentResolver which probably does what you want

Upvotes: 1

Related Questions