Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
@Config(constants = BuildConfig.class, sdk = DefaultConfig.EMULATE_SDK, manifest = DefaultConfig.MANIFEST)
public class PostViewModelTest {
private Context mContext;
private PostViewModel mPostViewModel;
private Post mPost;
public void setUp() {
mContext = RuntimeEnvironment.application;
mPost = MockModelsUtil.createMockStory();
mPostViewModel = new PostViewModel(mContext, mPost, false);
public void shouldGetPostScore() throws Exception {
String postScore = mPost.score + mContext.getResources().getString(R.string.story_points);
assertEquals(mPostViewModel.getPostScore(), postScore);
public void shouldGetPostTitle() throws Exception {
assertEquals(mPostViewModel.getPostTitle(), mPost.title);
public void shouldGetPostAuthor() throws Exception {
String author = mContext.getString(R.string.text_post_author,;
assertEquals(mPostViewModel.getPostAuthor().toString(), author);
public void shouldGetCommentsVisibility() throws Exception {
// Our mock post is of the type story, so this should return gone = null;
assertEquals(mPostViewModel.getCommentsVisibility(), View.GONE); = new ArrayList<>();
assertEquals(mPostViewModel.getCommentsVisibility(), View.VISIBLE); = null;
mPost.postType = Post.PostType.ASK;
assertEquals(mPostViewModel.getCommentsVisibility(), View.VISIBLE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment