package com.bnsantos.dagger.test;

import android.content.Context;
import android.os.Build;

import com.bnsantos.dagger.App;
import com.bnsantos.dagger.BuildConfig;
import com.bnsantos.dagger.Dagger2Helper;
import com.bnsantos.dagger.MainActivity;
import com.bnsantos.dagger.test.dagger.TestComponent;
import com.bnsantos.dagger.test.dagger.TestModule;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

/**
 * Created by bruno on 03/09/15.
 */
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class MainActivityTest {
    private MainActivity mMainActivity;
    private Context mContext;

    @Before
    public void setup() {
        //DaggerTestComponent.builder().testModule(new TestModule()).build()
        ((App)RuntimeEnvironment.application).setComponent(Dagger2Helper.buildComponent(TestComponent.class, new TestModule()));
        mContext = RuntimeEnvironment.application;
    }

    @Test
    public void testInitialState(){
        mMainActivity = Robolectric.buildActivity(MainActivity.class).get();
        //MainActivity activity = Robolectric.setupActivity(MainActivity.class);
        Assert.assertNotNull(mMainActivity);
        /*TextView version = (TextView) mMainActivity.findViewById(R.id.version);
        TextView value = (TextView) mMainActivity.findViewById(R.id.value);

        Assert.assertEquals("1", version.getText().toString());
        Assert.assertEquals("ProviderImpl", value.getText().toString());*/
    }
}

@@ -84,16 +84,48 @@
 s.Build;
+%0Aimport android.widget.TextView;
 %0A%0Aimport
@@ -273,16 +273,46 @@
 tivity;%0A
+import com.bnsantos.dagger.R;%0A
 import c
@@ -1385,18 +1385,16 @@
         
-//
 MainActi
@@ -1509,18 +1509,16 @@
         
-/*
 TextView
@@ -1531,38 +1531,33 @@
 on = (TextView) 
-mMainA
+a
 ctivity.findView
@@ -1612,22 +1612,17 @@
 xtView) 
-mMainA
+a
 ctivity.
@@ -1784,18 +1784,16 @@
 ring());
-*/
 %0A    %7D%0A%7D

Test working