I'm having a hard time testing, I was wondering if there is a possibility to simulate a custom return in a runtime method example:
@RunWith(JUnit4.class)
public class TesteSmile {
UserAndPass userAndPass = new UserAndPass();
@Rule
public ActivityTestRule<Exemplo> dashboard = new ActivityTestRule<>(Exemplo.class);
@Mock
public Customizacao customizacao = new customizacao();
@Before
public void setUp() throws Exception {
userAndPass = new UserAndPass();
}
@org.junit.Test
public void Main() throws InterruptedException {
DashboardNewActivity dashboardNewActivitsy = dashboard.getActivity();
customizacaoCliente.setTeste(true);
when(customizacaoCliente.getTeste()).thenReturn(false);
assertThat(false, customizacaoCliente.getTeste());
onView(withText("Item 1")).perform(click());
}
@After
public void unregisterIdlingResource() throws Exception{
//Intents.release();
}
}
This is just an example, I did not post everything, but only to base, I did mock a class, in this class I simulated a false return, and in assert it passes the test, because it returns the answer that I wanted in the get call, the whole problem is, I'm doing visual tests in the application and validating fields in general, except that this mock only mocks the local instance, which I created inside the test, is there any way to simulate a fake response in the running class? the test runs in the emulator of the android studio, opens the screens, tests the fields, validates errors using onview, more in a certain place I want to bring other elements, but this in visual screen (ui) do this without directly interfering with the class code?
At the end of the day I do not want this assert check but rather what I said above, visual feedback. (the code is merely an example)