BaseOAuthFragment extends Fragment { public void finishAuthorization() { SpotifyHelper.remove(); Intent intent = new Intent(getActivity(), MainActivity.class); startActivity(intent); getActivity().finish(); }  @Override View onCreateView(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState); WebViewClient getWebViewClient(); TokenGet getTokenAsyncTask(String authCode); @Override void onStart(); void superOnStart(); void startLogin(); String buildLoginUrl(); void finishAuthorization(); abstract String getLoginUrl(); abstract String getScope(); abstract String getTokenUrl(); abstract String getClientId(); abstract String getClientSecret(); abstract String getRedirectUri(); abstract String getGrantType(); abstract void saveAuthToken(String authToken, long expire, String refreshToken, String userId); public WebView loginWebView; }
@Test public void test_finishAuthorization() { Activity activity = Mockito.spy(fragment.getActivity()); doReturn(activity).when(fragment).getActivity(); fragment.finishAuthorization(); verify(fragment).startActivity(any(Intent.class)); verify(activity).finish(); }