title: Android Junit test with mockito
body: <p>Is my unit test code is correct?</p>
  
  <p><strong>LoginFragmentViewModel.java</strong></p>
  
  <pre><code>private final LoginRepository mLoginRepository;
      MutableLiveData&lt;String&gt; mLoginResponseLiveData;    
  
      public LoginFragmentViewModel() {
          mLoginRepository = new LoginRepository();
      }
  
      public LiveData&lt;String&gt; doLogin(String username, String password) {
          mLoginResponseLiveData = mLoginRepository.login(username, password);
          return mLoginResponseLiveData;
      }
  </code></pre>
  
  <p><strong>LoginFragmentViewModelTest.java</strong></p>
  
  <pre><code>@Test
  public void check_do_login(){
          LoginRepository loginRepository = mock(LoginRepository.class);
          MutableLiveData&lt;String&gt; mutableLiveData = mock(MutableLiveData.class);
          mutableLiveData.setValue("Testing value");
          when(loginRepository.login(anyString(), anyString())).thenReturn(mutableLiveData);
  
          LiveData&lt;String&gt; stringLiveData = mLoginFragmentViewModel.doLogin("username@gmail.com", "password@123");
          assertEquals(stringLiveData.getValue(),"Testing value");
  }
  </code></pre>