package com.abhi.fyberdemo.fragments;

import android.support.v4.app.Fragment;

import com.abhi.fyberdemo.MainActivity;
import com.abhi.fyberdemo.R;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.robolectric.Robolectric;

/**
 * Created by abhi on 28/10/16.
 */
public class FormFragmentTest {
    private MainActivity mMainActivity;
    private FormFragment mFormFragment;
    @Before
    public void setUp() throws Exception {
        mMainActivity = Robolectric.setupActivity(MainActivity.class);
        mFormFragment = FormFragment.newInstance(mMainActivity);
        startFragment(mFormFragment);
    }
    private void startFragment(Fragment fragment) {
        mMainActivity.getSupportFragmentManager()
                .beginTransaction()
                .add(R.id.frag_container, fragment)
                .commit();
    }
    @Test
    public void newInstance() throws Exception {
        Assert.assertNotNull(mMainActivity);
        Assert.assertNotNull(mFormFragment);
        Assert.assertNotNull(mFormFragment.getFragmentListener());
    }

    @Test
    public void getLayoutId() throws Exception {
        int layoutId = mFormFragment.getLayoutId();
        Assert.assertTrue("Layout Id can not be 0 ", layoutId != 0);
        Assert.assertTrue("Layout Id can not be negative ", layoutId > 0);
    }
}
@@ -73,16 +73,55 @@
 gment;%0A%0A
+import com.abhi.fyberdemo.BuildConfig;%0A
 import c
@@ -255,16 +255,49 @@
 t.Test;%0A
+import org.junit.runner.RunWith;%0A
 import o
@@ -328,48 +328,223 @@
 ic;%0A
-%0A/**%0A * Created by abhi on 28/10/16.%0A */
+import 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)
 %0Apub

Add Roboelectric Annotations in FormFragmentTest to remove MainActivity Looper error