package test.com.github.tmurakami.dexopener;

import android.support.test.rule.ActivityTestRule;
import android.support.v4.app.FragmentActivity;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import static org.junit.Assert.assertEquals;
import static org.mockito.BDDMockito.willReturn;

public class MyFragmentTest {

    @Rule
    public final ActivityTestRule<FragmentActivity> rule = new ActivityTestRule<>(FragmentActivity.class);

    @Mock
    MyService service;

    @InjectMocks
    MyFragment target;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void testOnCreate() {
        final Object o = new Object();
        willReturn(o).given(service).doIt();
        final FragmentActivity activity = rule.getActivity();
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                activity.getSupportFragmentManager().beginTransaction().add(target, null).commitNow();
                assertEquals(o, target.result);
            }
        });
    }

}

@@ -39,16 +39,69 @@
 pener;%0A%0A
+import android.support.test.InstrumentationRegistry;%0A
 import a
@@ -600,16 +600,29 @@
 ty.class
+, true, false
 );%0A%0A    
@@ -955,19 +955,22 @@
  = rule.
-get
+launch
 Activity
@@ -970,16 +970,20 @@
 ctivity(
+null
 );%0A     
@@ -1182,32 +1182,122 @@
 tNow();%0A        
+    %7D%0A        %7D);%0A        InstrumentationRegistry.getInstrumentation().waitForIdleSync();%0A
         assertEq
@@ -1324,34 +1324,8 @@
 t);%0A
-            %7D%0A        %7D);%0A
     

Fix to work on CI