TestMainActivity.java 862 B

12345678910111213141516171819202122232425262728293031323334
  1. package com.example.yiupang.freefoodfinder;
  2. import org.junit.Test;
  3. import java.lang.reflect.Method;
  4. import static org.hamcrest.CoreMatchers.instanceOf;
  5. import static org.junit.Assert.assertEquals;
  6. import static org.junit.Assert.assertThat;
  7. /**
  8. * Created by yiupang on 6/4/2017.
  9. *
  10. */
  11. public class TestMainActivity
  12. {
  13. @Test
  14. public void TestSwitchFragment()
  15. {
  16. AboutUsScreen expected = new AboutUsScreen();
  17. try
  18. {
  19. MainActivity m = new MainActivity();
  20. Method m1 = m.getClass().getDeclaredMethod("getSelectedFragement", int.class);
  21. m1.setAccessible(true);
  22. Object o = m1.invoke(m, 1);
  23. assertThat(expected, instanceOf(o.getClass()));
  24. }
  25. catch (Exception e)
  26. {
  27. System.out.println(e);
  28. }
  29. }
  30. }