@@ -0,0 +1,2443 @@
+package com.abhi.fyberdemo;%0A%0Aimport android.support.v4.app.Fragment;%0Aimport android.view.View;%0A%0Aimport com.abhi.fyberdemo.fragments.FormFragment;%0Aimport com.abhi.fyberdemo.fragments.OffersFragment;%0Aimport com.abhi.fyberdemo.models.OfferResponse;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mockito;%0Aimport org.robolectric.Robolectric;%0Aimport org.robolectric.RobolectricTestRunner;%0Aimport org.robolectric.annotation.Config;%0A%0A/**%0A * Created by abhi on 28/10/16.%0A */%0A@RunWith(RobolectricTestRunner.class)%0A@Config(constants = BuildConfig.class, sdk = 23)%0Apublic class MainActivityTest %7B%0A    private MainActivity mMainActivity;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        mMainActivity = Robolectric.setupActivity(MainActivity.class);%0A    %7D%0A%0A    @Test%0A    public void showFormFragment() throws Exception %7B%0A        mMainActivity.showFormFragment();%0A        Fragment _fragment = mMainActivity.getSupportFragmentManager().findFragmentById(R.id.frag_container);%0A        Assert.assertTrue(%22FormFragment is not displayed%22,_fragment.getClass()== FormFragment.class);%0A    %7D%0A%0A    @Test%0A    public void showOffersFragment() throws Exception %7B%0A        OfferResponse _offerResponse = Mockito.mock(OfferResponse.class);%0A        mMainActivity.showOffersFragment(_offerResponse);%0A        Fragment _fragment = mMainActivity.getSupportFragmentManager().findFragmentById(R.id.frag_container);%0A        Assert.assertTrue(%22FormFragment is not displayed%22,_fragment.getClass()== OffersFragment.class);%0A    %7D%0A%0A    @Test%0A    public void onOfferReceived() throws Exception %7B%0A        OfferResponse _offerResponse = Mockito.mock(OfferResponse.class);%0A        mMainActivity.onOfferReceived(_offerResponse);%0A        Fragment _fragment = mMainActivity.getSupportFragmentManager().findFragmentById(R.id.frag_container);%0A        Assert.assertTrue(%22FormFragment is not displayed%22,_fragment.getClass()== OffersFragment.class);%0A    %7D%0A%0A    @Test%0A    public void onShowProgress() throws Exception %7B%0A        mMainActivity.onShowProgress();%0A        Assert.assertTrue(%22ProgressBar is not displayed%22,mMainActivity.mProgressBar.getVisibility()== View.VISIBLE);%0A    %7D%0A%0A    @Test%0A    public void onHideProgress() throws Exception %7B%0A        mMainActivity.onHideProgress();%0A        Assert.assertTrue(%22ProgressBar is not hidden%22,mMainActivity.mProgressBar.getVisibility()== View.GONE);%0A    %7D%0A%0A%7D

Add Roboelectric Unit Test for MainActivity