Skip to content

Test for Applicaster, automatically refreshing twitter search with Caching

Notifications You must be signed in to change notification settings

danicheman/HashtagSearch2

Repository files navigation

HashtagSearch - Version 2

This test project for Applicaster, an automatically refreshing Twitter search with persisted history, provides Tweet results from the 10 most influential people.

Synopsis

In designing the search interface, the best practices from the Android Developers site were followed. The app allows you to configure the frequency for updating search results. After investigating Twitter4j, and interacting with Twitter's Web API directly in HashtagSearch Version 1, I ultimately decided to use Fabric's excellent Twitter Kit.

Twitter's Fabric sample app, demonstrates the simplest way to run Fabric with a custom OkHttp client. By combining several interceptor examples I was able to create an effective caching component for my custom OkHttp client.

Getting Started

Api Key Requirements

You'll need to have an account on Fabric.io and an API key for Twitter. Twitter integration was done with the assistance of the Fabric plugin for Android Studio

Building the project

With Api keys now available, to build the app, you'll need to create and populate those keys into the app/fabric.properties file. The Fabric for Android plugin will help with this, and you can also refer to the Fabric for Android sample app.

Sample fabric.properties file:

#These keys are provisioned on the plugin. Copy the keys on the plugin here.
twitterConsumerKey=EDIT_THIS
twitterConsumerSecret=EDIT_THIS

#Contains API Secret used to validate your application. Commit to internal source control; avoid making secret public.
apiKey=EDIT_THIS
apiSecret=EDIT_THIS

Testing

Unit tests with Robolectric

This project uses Robolectric for unit tests. Robolectric uses Android SDK version 22 for testing because newer versions throw unrelated OpenGL errors.

To setup Robolectric, you'll need to create a new Android JUnit configuration in Android Studio:

  • Set Test Kind: to All in package:
  • Set Package: to com.actest.nick.hashtagsearch2
  • Set Search for tests: to In single module
  • Set Working directory to $MODULE_DIR$.

Instrument tests with Espresso

Espresso instrument tests require that you have either an Android device attached or an emulator running. Once you have that, run a test by command-clicking/right-clicking a specific instrument test and choosing run. The run configuration will automatically be created and the test will be launched.

Acknowledgments

About

Test for Applicaster, automatically refreshing twitter search with Caching

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages