Quellcode durchsuchen

[공통][New] Unit Test

hyodong.min vor 7 Jahren
Ursprung
Commit
d5b387c8ed

+ 67 - 0
app/src/test/java/kr/co/zumo/app/lifeplus/activity/ActivityStarterTest.java

@@ -0,0 +1,67 @@
+package kr.co.zumo.app.lifeplus.activity;
+
+import android.content.Context;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import kr.co.zumo.app.lifeplus.model.LifeplusPreferences;
+import kr.co.zumo.app.lifeplus.model.SuperModel;
+
+import static org.powermock.api.mockito.PowerMockito.mock;
+import static org.powermock.api.mockito.PowerMockito.spy;
+import static org.powermock.api.mockito.PowerMockito.verifyPrivate;
+
+/**
+ * ActivityStarterTest
+ * <pre>
+ * </pre>
+ *
+ * @author 민효동
+ * @version 1.0
+ * @history 민효동   [2018. 10. 12.]   [최초 작성]
+ * @since 2018. 10. 12.
+ */
+public class ActivityStarterTest {
+  LifeplusPreferences lifeplusPreferences;
+  Context context;
+  ActivityStarter starter;
+
+  @Before
+  public void setup() {
+    lifeplusPreferences = mock(LifeplusPreferences.class);
+
+    SuperModel.getInstance().init(lifeplusPreferences);
+
+    context = mock(Context.class);
+    starter = spy(new ActivityStarter(context));
+  }
+
+  @Test
+  public void launch() {
+
+//    ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+//    doReturn(null).when(context.startService(any()));
+
+    starter.launch(false);
+
+//    PowerMockito.doReturn("someValue", spy, "privateMethod1");
+//    final String response = Whitebox.invokeMethod(spy, "anotherPrivateMethod");
+//    assert(response)
+    try {
+      verifyPrivate(starter).invoke("gotoScreen", NetworkErrorActivity.class);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+
+//    verify(context).startActivity(captor.capture());
+//    verify(context).startActivity(any());
+
+
+//    String intentAction = captor.getValue().getAction();
+
+//    System.out.print(captor.getValue());
+
+//    assertEquals("", intentAction);
+  }
+}